php抓取网页标签( 2018-12-27())

优采云 发布时间: 2021-10-16 00:27

  php抓取网页标签(

2018-12-27())

  Jsoup抓取页面A标签中的href路径

  时间:2018-12-27

  本文章为大家介绍Jsoup抓取到页面A标签的href路径,主要包括Jsoup抓取到页面A标签的href路径的使用示例、应用技巧、基础知识点总结及注意事项需要注意。有一定的参考价值,有需要的朋友可以参考。

  直接上代码,注释很全

<p>

public static void main(String[] args)throws Exception{

//抓取的网址

String url = "http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2017/index.html";

//编码格式的转换

Document document = Jsoup.parse(new URL(url).openStream(), "GBK", url);

//根据class获取到 页面的 元素内容

Elements tables = document.getElementsByClass("provincetr");

//根据td标签来划分

Elements td = tables.select("td");

for(int j=0;j

0 个评论

要回复文章请先登录注册


官方客服QQ群

微信人工客服

QQ人工客服


线