繁体   English   中英

使用Jsoup获取所有数据网络

[英]get all data web with Jsoup

我尝试获取所有数据网站,但使用erorr Line Document doc1 = Jsoup.connect(url).get(); 你帮帮我!

 public static void main(String[] args) throws IOException { File file = new File("out22.txt"); FileWriter fw = new FileWriter(file); PrintWriter pw = new PrintWriter(fw); Document doc = Jsoup.connect("https://vnexpress.net/").get(); String title = doc.title(); System.out.println("Title : " + title); Elements links = doc.select("a[href]"); for (Element link: links) { String url = link.attr("href"); //System.out.println("\\nLink: "+url); Document doc1 = Jsoup.connect(url).get(); Elements title1 = doc1.select("h1[class=title_news_detail mb10]"); Elements description = doc1.select("p[class=description]"); Elements content = doc1.select("p[class=Normal]"); String tieude = title1.text(); String noidung = content.text(); String mota = description.text(); System.out.println(noidung); pw.println(tieude); pw.println("\\n" + mota); pw.println("\\n" + noidung); pw.close(); 

您的URL使用请求标头进行过滤器连接。 如果要从中获取数据,则应使用硒。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM