0

查看源浏览器功能显示浏览器接收到的纯 HTML。当我在 Firefug 中查看相同的源代码时。例如,Firefox 向您显示 HTML 代码,而 Firebug 显示呈现的代码。有没有办法从 Java 的标准源代码中获取渲染代码?某个图书馆?

4

1 回答 1

1

如果您想获得呈现的 HTML,请尝试使用HtmlUnit。它会自动调用大多数 JavaScript 事件(onload、onclick、onsubmit...)并允许您充当“普通”浏览器:

WebClient webClient = new WebClient();
HtmlPage page = webClient.getPage("http://www.br.de/fernsehen/bayerisches-fernsehen/sendungen/abendschau/bayerwald-tierpark-livereportage-100.html");
DomNodeList<DomElement> objectList = page.getElementsByTagName("object");

编辑:

这与问题不一样吗:https ://stackoverflow.com/questions/15808354/java-convert-html-source-code-of-string-type-by-show-source-code-to-source ?

于 2013-04-04T14:47:47.477 回答