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");
*/ }
}

java抓取快递信息的更多相关文章

  1. PHP快速抓取快递信息

    <?php header("Content-type:text/html;charset=utf-8"); /** * Express.class.php 快递查询类 * @ ...

  2. java抓取快递100信息接口

    package zeze; import java.io.IOException; import org.json.JSONArray; import org.json.JSONException; ...

  3. HttpClient+Jsoup 抓取网页信息(网易贵金属为例)

    废话不多说直接讲讲今天要做的事. 利用HttpClient和Jsoup技术抓取网页信息.HttpClient是支持HTTP协议的客户端编程工具包,并且它支持HTTP协议. jsoup 是一款基于 Ja ...

  4. 网络爬虫: 从allitebooks.com抓取书籍信息并从amazon.com抓取价格(3): 抓取amazon.com价格

    通过上一篇随笔的处理,我们已经拿到了书的书名和ISBN码.(网络爬虫: 从allitebooks.com抓取书籍信息并从amazon.com抓取价格(2): 抓取allitebooks.com书籍信息 ...

  5. 网络爬虫: 从allitebooks.com抓取书籍信息并从amazon.com抓取价格(2): 抓取allitebooks.com书籍信息及ISBN码

    这一篇首先从allitebooks.com里抓取书籍列表的书籍信息和每本书对应的ISBN码. 一.分析需求和网站结构 allitebooks.com这个网站的结构很简单,分页+书籍列表+书籍详情页. ...

  6. java 抓取网页图片

    import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; import java.io.Out ...

  7. .net抓取网页信息 - Jumony框架使用1

    往往在实际开发中,经常会用到一些如抓取网站信息之类的的操作,往往大家采用的是用一些正则的方式获取,但是有时候正则是很死板的,我们常常试想能不能使用jquery的选择器,获取符合自己要求的元素,然后进行 ...

  8. SpringCloud系列九:SpringCloudConfig 基础配置(SpringCloudConfig 的基本概念、配置 SpringCloudConfig 服务端、抓取配置文件信息、客户端使用 SpringCloudConfig 进行配置、单仓库目录匹配、应用仓库自动选择、仓库匹配模式)

    1.概念:SpringCloudConfig 基础配置 2.具体内容 通过名词就可以发现,SpringCloudConfig 核心作用一定就在于进行配置文件的管理上.也就是说为了更好的进行所有微服务的 ...

  9. Web Scraper 高级用法——抓取属性信息 | 简易数据分析 16

    这是简易数据分析系列的第 16 篇文章. 这期课程我们讲一个用的较少的 Web Scraper 功能--抓取属性信息. 网页在展示信息的时候,除了我们看到的内容,其实还有很多隐藏的信息.我们拿豆瓣电影 ...

随机推荐

  1. 【MVC5】画面多按钮提交

    画面上有个多个按钮时,如何绑定到各自的Action上? 1.追加如下MultipleButtonAttribute类 1 using System; 2 using System.Reflection ...

  2. ] 解决myeclipse中新建javaweb工程,无法使用Web App Libraries问题

    ] 解决myeclipse中新建javaweb工程,无法使用Web App Libraries问题 标签: myeclipsejavawebWeb App Libraries 2013-10-16 1 ...

  3. Redis-cluster集群【第二篇】:redis持久化

    Redis持久化原理: Redis支持两种持久化:RDB和AOF模式 一.名词解释: RDB:持久化可以在指定的时间间隔内生成数据集的时间点快照(point-in-time snapshot).AOF ...

  4. Simple colum formatting in Yii 2 GridView

    A very important widget in the business apps development is the GridView control. In this post I wil ...

  5. target 事件属性

    定义和用法 target 事件属性可返回事件的目标节点(触发该事件的节点),如生成事件的元素.文档或窗口. 语法 event.target 实例 下面的例子可获得触发事件的元素: <html&g ...

  6. ASP.NET MVC 自己实现登陆验证过滤器

    1.首先添加一个过滤器类,并实现接口中对应的方法 public class YLFAuthorizeAttribute : FilterAttribute, IAuthorizationFilter ...

  7. android自定义控件(3)-自定义当前按钮属性

    那么还是针对我们之前写的自定义控件:开关按钮为例来说,在之前的基础上,我们来看看有哪些属性是可以自定义的:按钮的背景图片,按钮的滑块图片,和按钮的状态(是开还是关),实际上都应该是可以在xml文件中直 ...

  8. fedora各个版本的下载地址archive

    archive: ['a:kaiv] she went to the city archive this morning. ==================== === fedora 的下载地址是 ...

  9. ggplot2 上篇

    title: "ggplot2 上篇" author: "li_volleyball" date: "2016年4月16日" output: ...

  10. Ruby学习之module

    我们可以认为module是一个专门存放一系列方法和常量的工具箱. module和class非常像, 只是module不能创建实例也不能有子类, 它们仅仅能存放东西. 例如: module Circle ...