简体   繁体   English

如何强制jsoup等待网页完全加载

[英]How to force jsoup to wait for a webpage to load completely

The website I am using jsoup to parse loads incrementally. 我正在使用jsoup来逐步解析加载的网站。 The data I am trying to access loads into the page after a couple of seconds but jsoup only gets everything that was loaded initially. 我试图访问的数据在几秒钟后加载到页面中,但jsoup只获取最初加载的所有内容。

Is there a way to force jsoup to wait for the page to load completely before attempting to parse it or to build in a delay to allow the page to load completely? 有没有办法强制jsoup在尝试解析之前等待页面完全加载,或者构建一个延迟以允许页面完全加载?

Jsoup can't deal with such a requirement. Jsoup无法处理这样的要求。 Jsoup simply interprets HTML (The wait is because of some AJAX call done after page load, since you have mentioned the page loads incrementally). Jsoup只是解释HTML(等待是因为在页面加载后完成了一些AJAX调用,因为你已经提到了页面加载的增量)。

Alternate would be to use Selenium which can emulate your browser and handle these elegantly. 替代方法是使用Selenium,它可以模拟您的浏览器并优雅地处理这些。

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

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