user2461831
user2461831

Reputation: 7

How to download Html Content / Source of a webpage using HtmlUnit

Using HtmlUnit I want to download the source code of an html page. I did that successfully (see code below).

htmlContents = HtmlPageFetcher.fetchPage(
    "https://dbs-careers.dbs.com.sg/psc/careers/EMPLOYEE/HRMS/c/HRS_HRAM.HRS_CE.GBL");
System.out.println(htmlContents);

Now for the same site I want to download the next page (page no 2) But I dont have the url for the next page (or I should say next page is also using the same url as used by previous page) can any body help on this? How to download the content of the page no 2, 3, 4 and so on?????

Upvotes: 0

Views: 347

Answers (2)

Afshin Moazami
Afshin Moazami

Reputation: 2098

Possible duplicate of How do I click a javascript button with htmlunit?

As Mosty said, the page uses AJAX to navigate between pages. So, you need to trigger the javascript function to get the next page result.

You can use the answer of Clyde Lobo

Try using this addOn for firefox, it records your actions and generates the HTMLUnit code for the same. may be it could help. http://code.google.com/p/htmlunitscripter/

Upvotes: 0

Mosty Mostacho
Mosty Mostacho

Reputation: 43494

You will have to use AJAX to get that page. If you know what it is then just refer to the HtmlUnit documentation and see how to work with it. If you don't know what AJAX is (based on the question this is very likely) then I'd recommend first learning how to work with AJAX and then follow the HtmlUnit documentation.

Upvotes: 1

Related Questions