只有在页面完全加载后才填充文档 [英] Populate doc only after the page is completely loaded
问题描述
我从特定网站检索数据。 < sup>
中的< a>
仅在页面完全加载后才可用iejavascript将<
I am retrieving data form a certain website. The <a>
inside <sup>
is available only after the page is completely loaded i.e.javascript adds the <a>
tag to the page.
<table>
<tr>
<td class="left ">
<a href="reference" >Refer</a>see this
<sup class="super"><a href="#src1" onclick="dosomething;" title="1" >1</a></sup>
</td>
<td class="td_right2" style="padding-top: .25em"></td>
</tr>
..
</table>
所以,当我做的时候
Document doc=JSoup.connect(...).userAgent(...).get();
文件不包含< a>
标签。
我如何确保文档也使用'a'标签填充.JSoup中的任何函数与JQuery中的 .ready
类似?
The doc doesnot contain the <a>
tag.
How do I make sure that the doc gets populated with 'a' tag as well.Is there any function in Jsoup similar to .ready
in JQuery?
推荐答案
Jsoup是一个HTML解析器,而不是webbrowser。像大多数HTML解析器一样,Jsoup不执行任何JavaScript代码。
Jsoup is a HTML parser, not a webbrowser. Like as most HTML parsers, Jsoup doesn't execute any JavaScript code.
您需要一个可以执行JavaScript的HTML解析器。 就是这样,它是一个无GUI界面的浏览器,专为单元测试而设计,能够执行包含JavaScript的页面在可能修改HTML DOM树的网页中。您可以尝试使用它。
You need instead a HTML parser which can execute JavaScript. HtmlUnit is such one, it's a GUI-less webbrowser designed for unit-testing purposes and is capable of executing JavaScript contained in the webpage which may modify the HTML DOM tree. You could try using it instead.
这篇关于只有在页面完全加载后才填充文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!