简体   繁体   中英

How can I get a pages content after it has fully loaded?

I have a web page whose contents I need to get as a string.

Some of the content is loaded via javascript after the page has fully loaded.

Doing

URL url = new URL("http:example.com/");
URLConnection con = url.openConnection();
InputStream is = con.getInputStream();

will not work as I cannot get the content that is loaded later.

Any ideas as to how I an achieve this?

It does not work because the content is loaded later, it doesn't work because nothing is executing the javascript. You'd need a javascript engine (typically a browser) to do that, which you don't have in your setup.

You can embed some kind of browser if you really want to, but you probably don't. Depending on the use case there might be simpler alternatives.

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