简体   繁体   中英

Java - library to generate source code changed e.g. by JavaScript from normal source code from browser?

the view source browser feature shows the plain HTML as received by the browser. When I look at the same source code in Firefug. For example Firefox shows you the HTML code, while Firebug shows the rendered code. Is there any way to obtain rendered code from standard source code in Java? Some library?

If you'd like to get rendered HTML, try to use HtmlUnit . It invokes most of the JavaScript events (onload, onclick, onsubmit...) automatically and allows you to act as "normal" browser:

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");

Edited:

Isn't this the same as the question: https://stackoverflow.com/questions/15808354/java-convert-html-source-code-of-string-type-by-show-source-code-to-source ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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