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