简体   繁体   中英

How do I get the source HTML for a page after executing its associated JavaScript?

there have been quiet a few posts on that issue but it seems none realy answer the question I have.

I use TIdHttp to load the source code of this website: http://www.nationalgeographic.com/

I try to extract some data but realized that the data is generated by a script. There is a script on in the source code and a few links to external js files.

How could i possibly run some or all of the scripts on the page and get the source code generated ?

I am using this part in a secondary thread and would like to avoid using a WebBrowser component.

I could extract the scripts or links from the Idhttp generated source code, but running a js file with idhttp.get(*.js) but I presume that would probably be too simple to work.

Finally, the answer have been very basic :

document := webBrowser.Document as IHTMLDocument2; result := document.body.innerHTML;

That retrieves the source code and include the content generated dynamically at runtime by scripts.

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