网络爬虫httpclient与jsoup解析

模拟爬取51job网站的信息

//爬取对象
HttpClient httpClient = new HttpClient();
//创建爬取方法
GetMethod method= new GetMethod("http://www.51job.com/");
//开始爬取
httpClient.executeMethod(method);
//获取一个页面返回的字符串,即html标签
String html = method.getResponseBodyAsString();
//System.out.println(html);
//停止爬取,关闭连接
method.releaseConnection();
//将返回的页面存放在F的doc目录下
FileUtil util = new FileUtil();
String path="F:\\doc\\51job.html";
util.file(path,html);
//Jsoup类解析html,返回一个文档对象
Document doc = Jsoup.parse(html);


//模拟登陆请求
HttpClient httpClient = new HttpClient();
PostMethod method= new PostMethod("http://www.51job.com/");
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值