Search code examples
ajaxdownloadhtmlunit

HtmlUnit Axaj file download


I'm trying to download the XLS file from this page: http://www.nordpoolspot.com/Market-data1/Elspot/Area-Prices/ALL1/Hourly/ (click on "Export to XLS" link).

However doing:

page.getAnchorByText("Export to XLS").click().getWebResponse().getContentAsStream();

returns the html of the web page, instead of the expected file.

Do you have any suggestion?

I already tried the 3 points here http://htmlunit.sourceforge.net/faq.html#AJAXDoesNotWork without success.


Solution

  • The following:

    webClient = new WebClient(BrowserVersion.FIREFOX_3_6);
    

    fixed my issue.