使用JSOUP通过URL解析整个html(平均大小20MB)

时间:2019-03-28 06:47:57

标签: java jsoup html-parsing html-parser

Document document = Jsoup.connect("some html url").get();
Elements catelist=  document.select("TEXT");

以上代码未提供完整的html。

2 个答案:

答案 0 :(得分:1)

默认情况下,最大主体大小限制为1MB。您可以使用maxBodySize(int)更改默认值:

//for example to set the max body size to 20 MB
Document document = Jsoup.connect(some html url).timeout(0).maxBodySize(1024*1024*20).get();

//or set it to 0 to have an unlimited size
Document document = Jsoup.connect(some html url).timeout(0).maxBodySize(0).get();

答案 1 :(得分:0)

如果要整页的html代码 然后使用:

document.html();

如果您想要特定标签的html代码 然后使用:

catelist.html();