首页 > Web开发 > 详细

jsoup的基本写法

时间:2014-04-12 22:33:59      阅读:492      评论:0      收藏:0      [点我收藏+]

jsoup这个工具用于抓取并解析网页,用起来也比较简单,语法上与Jquery类似,基本写法如下:

 

File input = new File("/tmp/input.html");
        Document doc = Jsoup.parse(input, "UTF-8", "http://www.oschina.net/");
        Elements links = doc.select("a[href]"); // 链接
        Elements pngs = doc.select("img[src$=.png]"); // 所有 png 的图片
        Element masthead = doc.select("div.masthead").first();// div with class="masthead"
        Elements resultLinks = doc.select("h3.r > a"); // direct a after h3 

jsoup的基本写法,布布扣,bubuko.com

jsoup的基本写法

原文:http://www.cnblogs.com/attlia/p/3660701.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!