Two-color ball in 2013 statistics, crawlers from the Internet

Source: Internet
Author: User
Package COM. HPU. bai; import Java. io. bufferedreader; import Java. io. bufferedwriter; import Java. io. file; import Java. io. fileoutputstream; import Java. io. filewriter; import Java. io. ioexception; import Java. io. writer; import java.net. URL; import Org. jsoup. jsoup; import Org. jsoup. nodes. document; import Org. jsoup. nodes. element; import Org. jsoup. select. elements; public class double2013 {public static void main (string [] ARGs) throws exception {document DOC; file = new file ("D: \ dual-color ball stage 2013015to 2013154 final result .txt "); fileoutputstream Fos = new fileoutputstream (File); // while (true) {for (INT I = 2013015; I <= 2013154; I ++) {string url = "http://caipiao.163.com/award/ssq/" + I + ". html "; Doc = (document) jsoup. connect (URL ). get (); // String title = Doc. title (); // elements ele = Doc. select ("Div. search_zj_left p. red_ball span "); element content = Doc. getelementbyid ("zj_area"); elements links = content. getelementsbytag ("span"); // system. out. println (links. size (); int COUNT = 0; byte [] B = new byte [1024]; for (element link: Links) {count ++; // string linkhref = link. ATTR ("href"); string linktext = link. text (); // system. out. print (linkhref); system. out. print ("" + linktext); // linktext. tochararray (); linktext = "" + linktext; B = linktext. getbytes (); FOS. write (B); If (count % 7 = 0) {FOS. write ("\ r \ n ". getbytes ();} system. out. println (); // string ball = ELE. text ();/* element dayfav = Doc. getelementsbyattributevalue ("class", "linkright "). first (); elements dayfavitems = dayfav. getelementsbytag ("A"); For (element dayfavitem: dayfavitems) {system. out. println (dayfavitem. text ();} * // system. out. println (title); // system. out. println (ball); thread. sleep (1500);} //} FOS. flush (); FOS. close ();}}

Jsoup is used, but it is not very useful yet. QQ: 623687677. Java beginners

Two-color ball in 2013 statistics, crawlers from the Internet

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.