Is it possible to save an image to hard disk with HTMLUnit by giving it the image URL? If so how?
Regards!
If you're using HtmlUnit then you should have an HtmlPage. There you can get an HtmlImage and save the file this way:
HtmlImage image = page.<HtmlImage>getFirstByXPath("//img[@src='blah']");
File imageFile = new File("/path/to/file.jpg");
image.saveAs(imageFile);
If you do have an URL... then I don't think you need HtmlUnit to download the image.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With