2

Possible Duplicate:
Getting Final HTML with Javascript rendered Java as String

I have the following 2 links in both of them the reviews section is generated using Javascript. Is there a way that I can get the final output of page i.e. the one with javascript rendered in Java?

http://www.glamsham.com/movies/reviews/rowdy-rathore-movie-review-cheers-for-rowdy-akki-051207.asp

http://www.imdb.com/title/tt0461936/reviews

1

2 Answers 2

1

You should be able to use PhantomJS for this. It's runs as headless browser (using WebKit) and has native support for various web standards like DOM handling, CSS selectors, JSON, Canvas, and SVG.

Sign up to request clarification or add additional context in comments.

2 Comments

But it is for Javascript I want something similar for Java.
This could easily be used, because java can execute an external program and collect the result.
0

You can use HTML Unit, A java based "GUI LESS Browser". You can easily get the final rendered output of any page because this loads the page as a web browser do so and returns the final rendered output. You can disable this behaviour though.

UPDATE: You were asking for example? You don't have to do anything extra for doing that:

Example:

WebClient webClient = new WebClient();
HtmlPage myPage = ((HtmlPage) webClient.getPage(myUrl));

UPDATE 2: You can get iframe as follows:

HtmlPage myFrame = (HtmlPage) myPage.getFrameByName(myIframeName).getEnclosedPage();

Please read the documentation from above link. There is nothing you can't do about getting page content in HTMLUnit

3 Comments

Can you give me an example to do this? I tried but wasn't able to figure out how to use it.
I am working on it. Tried it on IMDB link the page is returned but comments are not. So the code behind is not executed just the main HTML content is returned no results from frames or Javascript.
This is extremely slow and doesn't render the page correctly at all pages.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.