[HtmlUnit] [htmlunit:bugs] #2020 Unable to save image locally from HtmlImage object
RBRi via HtmlUnit-develop <[email protected]> Thu, 11 Jul 2019 18:44:07 -0000
| Newsgroups | gmane.comp.java.htmlunit.devel |
|---|---|
| Message-ID | </p/htmlunit/bugs/2020/085bf77a1f493952ecc8e9d95310649a75667a88.bugs@htmlunit.p.sourceforge.net> |
This is a multi-part message in MIME format.
--===============7949688549185226395==
Content-Type: multipart/related;
boundary="===============6323012873947672933=="
This is a multi-part message in MIME format.
--===============6323012873947672933==
Content-Type: multipart/alternative;
boundary="===============5377657358803550202=="
MIME-Version: 1.0
--===============5377657358803550202==
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Hi,
first of all you are using a really really outdated version of HtmlUnit. If you like to get any support use the latest version.
Second: No image response available (src=) looks like there is no src value in the img tag in the page. Maybe some javascript fill the image.
If you really like more detailed support you have to add more details to give me a chance to reproduce your case.
---
** [bugs:#2020] Unable to save image locally from HtmlImage object**
**Status:** open
**Group:** 2.35.0
**Created:** Thu Jul 11, 2019 04:58 AM UTC by raman palikala
**Last Updated:** Thu Jul 11, 2019 04:58 AM UTC
**Owner:** nobody
**Attachments:**
- [Image_Content_As_JSON.txt](https://sourceforge.net/p/htmlunit/bugs/2020/attachment/Image_Content_As_JSON.txt) (2.0 kB; text/plain)
Hi Team,
I have just started exploring HtmlUnit.
I am using htmlunit v2.21.
The problem is I am unable to save image from HtmlImage object.
Below is my sample code :
HtmlImage image = (HtmlImage) page
.getByXPath("//img[@id='captchaDetailImg' and @class='bordered-desktop']")
.get(0);
File captchaFile = new File(newFilePathOfImage);
image.saveAs(captchaFile);
Here, in the above code when **image.saveAs(captchaFile);**
is executed it is throwing the following error:
**java.io.IOException: No image response available (src=)**
When I observed the same html page in the browser to identify the cause of the error, I noticed that it is due to the image in the page not being transferred as a file, but the image did come as a response of type application/json.
And that json content is of binary and I am not able to see the properties and their values in the json content. Please find the attached which has the response in json for the image.
Could you please let me know what I have to do to construct the image from the json content
OR is there any way to get the image directly or save it locally from the HtmlImage object in this
scenario?
Awaiting for your response.
Thanks and regards,
Raman Palikala.
---
Sent from sourceforge.net because [email protected] is subscribed to https://sourceforge.net/p/htmlunit/bugs/
To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/htmlunit/admin/bugs/options. Or, if this is a mailing list, you can unsubscribe from the mailing list.
--===============5377657358803550202==
MIME-Version: 1.0
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: 7bit
<div class="markdown_content"><p>Hi,</p>
<p>first of all you are using a really really outdated version of HtmlUnit. If you like to get any support use the latest version.</p>
<p>Second: No image response available (src=) looks like there is no src value in the img tag in the page. Maybe some javascript fill the image.<br/>
If you really like more detailed support you have to add more details to give me a chance to reproduce your case.</p>
<hr/>
<p><strong> <a class="alink" href="https://sourceforge.net/p/htmlunit/bugs/2020/">[bugs:#2020]</a> Unable to save image locally from HtmlImage object</strong></p>
<p><strong>Status:</strong> open<br/>
<strong>Group:</strong> 2.35.0<br/>
<strong>Created:</strong> Thu Jul 11, 2019 04:58 AM UTC by raman palikala<br/>
<strong>Last Updated:</strong> Thu Jul 11, 2019 04:58 AM UTC<br/>
<strong>Owner:</strong> nobody<br/>
<strong>Attachments:</strong></p>
<ul>
<li><a class="" href="https://sourceforge.net/p/htmlunit/bugs/2020/attachment/Image_Content_As_JSON.txt">Image_Content_As_JSON.txt</a> (2.0 kB; text/plain)</li>
</ul>
<p>Hi Team,</p>
<p>I have just started exploring HtmlUnit.<br/>
I am using htmlunit v2.21.<br/>
The problem is I am unable to save image from HtmlImage object.</p>
<p>Below is my sample code :</p>
<p>HtmlImage image = (HtmlImage) page<br/>
.getByXPath("//img<span>[@id='captchaDetailImg' and @class='bordered-desktop']</span>")<br/>
.get(0);<br/>
File captchaFile = new File(newFilePathOfImage);<br/>
image.saveAs(captchaFile);</p>
<p>Here, in the above code when <strong>image.saveAs(captchaFile);</strong><br/>
is executed it is throwing the following error:<br/>
<strong>java.io.IOException: No image response available (src=)</strong></p>
<p>When I observed the same html page in the browser to identify the cause of the error, I noticed that it is due to the image in the page not being transferred as a file, but the image did come as a response of type application/json.<br/>
And that json content is of binary and I am not able to see the properties and their values in the json content. Please find the attached which has the response in json for the image.</p>
<p>Could you please let me know what I have to do to construct the image from the json content<br/>
OR is there any way to get the image directly or save it locally from the HtmlImage object in this <br/>
scenario?<br/>
Awaiting for your response.</p>
<p>Thanks and regards,<br/>
Raman Palikala.</p>
<hr/>
<p>Sent from sourceforge.net because [email protected] is subscribed to <a href="https://sourceforge.net/p/htmlunit/bugs/">https://sourceforge.net/p/htmlunit/bugs/</a></p>
<p>To unsubscribe from further messages, a project admin can change settings at <a href="https://sourceforge.net/p/htmlunit/admin/bugs/options.">https://sourceforge.net/p/htmlunit/admin/bugs/options.</a> Or, if this is a mailing list, you can unsubscribe from the mailing list.</p></div>
--===============5377657358803550202==--
--===============6323012873947672933==--
--===============7949688549185226395==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
--===============7949688549185226395==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
HtmlUnit-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop
--===============7949688549185226395==--