package zeze; import java.io.IOException; import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements; public class TestJsoup { public Document getDocument(String url) {
try {
return Jsoup.connect(url).get();
} catch (IOException e) {
e.printStackTrace();
}
return null;
} public static void main(String[] args) throws IOException {
TestJsoup t = new TestJsoup();
String url ="http://www.kiees.cn/yto.php?wen=880350384879600241&action=ajax";//获取地址
Connection conn = Jsoup.connect(url);
// 设置查询参数
conn.data("wen", "880350384879600241");
Document doc = null;
// 设置请求类型
doc = conn.timeout(100000).get();
//处理返回数据
Elements results = new Elements();
results = doc.select("[class = yto]");
int i=0;
for (Element result : results)
{
Elements links = result.getElementsByTag("td");
for (Element link : links)
{
//必要的筛选
String val = link.text();
if(i%2==0)
System.out.println("时间:" + val);
else
System.out.println("状态:" + 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=" + key + "");
String b = key.substring(0, 5); String c = key.substring(5, 12); int d = Integer.parseInt(c);
key = b + (d + 1);
// 获取目标HTML代码
zeze0 = doc.select("[class= tb-main-title]");
name = zeze0.attr("data-title");//商品名 zeze1 = doc.select("[class=tb-rmb-num]");
price = zeze1.text();//价格 zeze2 = doc.select("#J_SellCounter");
sales = zeze2.text();//销量 if (name != "") {
count++;
System.out.println("id:" + key);
System.out.println("商品:" + name);
System.out.println("价格:" + price);
System.out.println("销量:" + sales);
}
}
System.out.println("本次采集总数:"+count);
System.out.println("end");*/ }
}
package zeze; import java.io.IOException; import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements; public class TestJsoup { public Document getDocument(String url) {
try {
return Jsoup.connect(url).get();
} catch (IOException e) {
e.printStackTrace();
}
return null;
} public static void main(String[] args) throws IOException {
TestJsoup t = new TestJsoup();
String url = "http://www.zto.cn/GuestService/Bill";// 获取地址
Connection conn = Jsoup.connect(url); String key = "368853112593"; // 设置查询参数
for (int j = 0; j < 100; j++) {
String b = key.substring(0, 8);
String c = key.substring(8,12);
int d = Integer.parseInt(c);
key = b + (d + 1);
System.out.println("key:" + key);
conn.data("txtBill", key);
Document doc = null;
// 设置请求类型
doc = conn.post();
// 处理返回数据
Elements results = new Elements();
results = doc.select("[class = state]");
int i = 0;
for (Element result : results) {
Elements links = result.select("[class = routeTips]");
for (Element link : links) {
// 必要的筛选
String val = link.text();
if (i % 2 == 0)
System.out.println("时间:" + val);
else
System.out.println("状态:" + 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=" + key + "");
* String b = key.substring(0, 5);
*
* String c = key.substring(5, 12);
*
* int d = Integer.parseInt(c); key = b + (d + 1); // 获取目标HTML代码 zeze0 =
* doc.select("[class= tb-main-title]"); name =
* zeze0.attr("data-title");//商品名
*
* zeze1 = doc.select("[class=tb-rmb-num]"); price = zeze1.text();//价格
*
* zeze2 = doc.select("#J_SellCounter"); sales = zeze2.text();//销量
*
*
* if (name != "") { count++; System.out.println("id:" + key);
* System.out.println("商品:" + name); System.out.println("价格:" + price);
* System.out.println("销量:" + sales); } }
* System.out.println("本次采集总数:"+count); System.out.println("end");
*/ }
}
package zeze; import java.io.IOException; import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements; public class TestJsoup { public Document getDocument(String url) {
try {
return Jsoup.connect(url).get();
} catch (IOException e) {
e.printStackTrace();
}
return null;
} public static void main(String[] args) throws IOException {
TestJsoup t = new TestJsoup();
String url = "http://www.kiees.cn/yto.php?wen=880350384879600241&action=ajax";// 获取地址
Connection conn = Jsoup.connect(url); String key = "880350384879600241"; // 设置查询参数
for (int j = 0; j < 100; j++) {
String b = key.substring(0, 11);
String c = key.substring(11,17);
int d = Integer.parseInt(c);
key = b + (d + 1);
System.out.println("key:" + key);
conn.data("wen", key);
Document doc = null;
// 设置请求类型
doc = conn.timeout(100000).get();
// 处理返回数据
Elements results = new Elements();
results = doc.select("[class = yto]");
int i = 0;
for (Element result : results) {
Elements links = result.getElementsByTag("td");
for (Element link : links) {
// 必要的筛选
String val = link.text();
if (i % 2 == 0)
System.out.println("时间:" + val);
else
System.out.println("状态:" + 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=" + key + "");
* String b = key.substring(0, 5);
*
* String c = key.substring(5, 12);
*
* int d = Integer.parseInt(c); key = b + (d + 1); // 获取目标HTML代码 zeze0 =
* doc.select("[class= tb-main-title]"); name =
* zeze0.attr("data-title");//商品名
*
* zeze1 = doc.select("[class=tb-rmb-num]"); price = zeze1.text();//价格
*
* zeze2 = doc.select("#J_SellCounter"); sales = zeze2.text();//销量
*
*
* if (name != "") { count++; System.out.println("id:" + key);
* System.out.println("商品:" + name); System.out.println("价格:" + price);
* System.out.println("销量:" + sales); } }
* System.out.println("本次采集总数:"+count); System.out.println("end");
*/ }
}