PackageZeze;Importjava.io.IOException;Importorg.jsoup.Connection;ImportOrg.jsoup.Jsoup;Importorg.jsoup.nodes.Document;Importorg.jsoup.nodes.Element;Importorg.jsoup.select.Elements; Public classTestjsoup { PublicDocument getdocument (String url) {Try { returnjsoup.connect (URL). get (); } Catch(IOException e) {e.printstacktrace (); } return NULL; } Public Static voidMain (string[] args)throwsIOException {testjsoup T=NewTestjsoup (); String URL= "Http://www.kiees.cn/yto.php?wen=880350384879600241&action=ajax";//Get AddressConnection conn =jsoup.connect (URL); //Set Query ParametersConn.data ("Wen", "880350384879600241"); Document Doc=NULL; //Set Request Typedoc = Conn.timeout (100000). get (); //Processing return DataElements results =NewElements (); Results= Doc.select ("[class = Yto]"); intI=0; for(Element result:results) {Elements links= Result.getelementsbytag ("TD"); for(Element link:links) {//Necessary ScreeningString val =Link.text (); if(i%2==0) System.out.println ("Time:" +val); ElseSystem.out.println ("Status:" +val); I++; } } /*Elements zeze0 = new Elements (); Elements zeze1 = new Elements (); Elements zeze2 = new Elements (); String name; String Price; String sales; int count=0; String key = "520675407117"; for (int i = 0; i < 3; i++) {Document doc = t.getdocument ("https://item.taobao.com/item.htm?id=*/ }}
1 PackageZeze;2 3 Importjava.io.IOException;4 5 Importorg.jsoup.Connection;6 ImportOrg.jsoup.Jsoup;7 Importorg.jsoup.nodes.Document;8 Importorg.jsoup.nodes.Element;9 Importorg.jsoup.select.Elements;Ten One Public classTestjsoup { A - PublicDocument getdocument (String url) { - Try { the returnjsoup.connect (URL). get (); -}Catch(IOException e) { - e.printstacktrace (); - } + return NULL; - } + A Public Static voidMain (string[] args)throwsIOException { atTestjsoup T =NewTestjsoup (); -String url = "Http://www.kiees.cn/yto.php?wen=880350384879600241&action=ajax";//Get Address -Connection conn =jsoup.connect (URL); - -String key = "880350384879600241"; - in //Set Query Parameters - for(intj = 0; J < 100; J + +) { toString B = key.substring (0, 11); +String C = key.substring (11,17); - intD =Integer.parseint (c); theKey = B + (d + 1); *System.out.println ("Key:" +key); $Conn.data ("Wen", key);Panax NotoginsengDocument doc =NULL; - //Set Request Type thedoc = Conn.timeout (100000). get (); + //Processing return Data AElements results =NewElements (); theResults = Doc.select ("[class = Yto]"); + inti = 0; - for(Element result:results) { $Elements links = Result.getelementsbytag ("TD"); $ for(Element link:links) { - //Necessary Screening -String val =Link.text (); the if(i% 2 = = 0) -System.out.println ("Time:" +val);Wuyi Else theSystem.out.println ("Status:" +val); -i++; Wu } - } About } $ - /* - * Elements zeze0 = new Elements (); Elements zeze1 = new Elements (); - * Elements zeze2 = new Elements (); String name; String Price; String A * sales; int count=0; String key = "520675407117"; for (int i = 0; i < + * 3; i++) {Document doc = the * T.getdocument ("https://item.taobao.com/item.htm?id="+ key +" "); - * String b = key.substring (0, 5); $ * the * String C = key.substring (5, n); the * the * int d = integer.parseint (c); key = B + (d + 1);//Get target HTML code ZEZE0 = the * Doc.select ("[class= tb-main-title]"); name = - * ZEZE0.ATTR ("data-title");//Product name in * the * zeze1 = Doc.select ("[Class=tb-rmb-num]"); price = Zeze1.text ();//Prices the * About * zeze2 = Doc.select ("#J_SellCounter"); sales = Zeze2.text ();//Sales the * the * the * IF (name! = "") {count++; SYSTEM.OUT.PRINTLN ("ID:" + key); + * SYSTEM.OUT.PRINTLN ("Product:" + name); SYSTEM.OUT.PRINTLN ("Prices:" + price); - * SYSTEM.OUT.PRINTLN ("Sales:" + sales);} } the * SYSTEM.OUT.PRINTLN ("Total number of this acquisition:" +count); System.out.println ("End");Bayi */ the the } -}
View Code
Java Crawl Courier Information