HtmlUnit : pulling down and saving image

Htmlunit doesn't fetch images or put in a right manner HtmlUnit version 1.14 does not

provide a direct method to download and save image but it can possible with following

approach

Lets say you have HtmlPage Object.


final HtmlImage img = pageRP.getXXX // Retrieve the img node here

final Page imagePage = webClient.getPage(pageRP.getFullyQualifiedUrl(img.getSrcAttribute()));

The imagePage will be of type com.gargoylesoftware.htmlunit.UnexpectedPage.

At this point you have access to the binary content of the page.

Now using java.io you can donwload and save image.

--

RS