Skip to content Skip to sidebar Skip to footer

Htmlunit Download File

I am trying to download file via HTMLUnit. But every time when I use code like this: InputStream stream = anchor.click().getWebResponse().getContentAsStream(); i get website inst

Solution 1:

Page page = anchor.click();
BinaryPage bp = new BinaryPage(page.getWebResponse(),page.getEnclosingWindow());
InputStream input = bp.getInputStream();

What is inside your page? Maybe it is a 40X or other 50X error page?


Solution 2:

If you want get page see below:

  final HtmlPage enclosedPage = (HtmlPage) anchor.click().getEnclosingWindow().getEnclosedPage();

Post a Comment for "Htmlunit Download File"