# Open URI & web scraping. (Sorry for crosspost)

**URL:** <https://www.ruby-forum.com/t/open-uri-web-scraping-sorry-for-crosspost/120067>\
**Category:** Rails\
**Created:** [November 13, 2007, 3:01pm UTC](https://www.ruby-forum.com/t/open-uri-web-scraping-sorry-for-crosspost/120067 "2007-11-13T15:01:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeannibee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/85e7bf/32.png) [@jeannibee](https://www.ruby-forum.com/u/jeannibee)\
**Post date:** [November 13, 2007, 3:01pm UTC](https://www.ruby-forum.com/t/open-uri-web-scraping-sorry-for-crosspost/120067/1 "2007-11-13T15:01:48Z")

</div>

Hi

I originally posted this to the Ruby forum but lack of responses (Aside  
from one that was nice but didn’t solve my problem) I’m hoping the ‘web’  
people her may know what I’m doing wrong.

I’m sorry but this is NOT rails specific… more “WEB” specific.

Thanks for understanding.

Nutshell if I use open URI (and Hpricot) to download a web page and  
‘scrape’ all the images to write them to my local disk dynamic images  
always have improper format (Size 0) but static images are fine.

Example would be : ![](http://myserver:8080/Someservlet?name=blah&param=value&etc=etc)

Whether I copy/paste this URL in another browser or use open URI to  
“get” the image I get an an error of:

XML Parsing Error: no element found  
Location: [http://myserver:8080/Someservlet?name=blah&param=value&etc=etc](http://myserver:8080/Someservlet?name=blah&param=value&etc=etc)  
Line Number 1, Column 1:

BUT, this image is displayed PERFECTLY in the html.

How can I get this image to download? (I suspect it’s the mime type  
being set on the server side but I am not 100% sure)

* * *

OUTPUT

* * *

[[URI information…]]  
Fetched document:  
[http://myserver:8080/Someservlet?name=blah&param=value&etc=etc](http://myserver:8080/Someservlet?name=blah&param=value&etc=etc)  
Content Type: application/voicexml+xml  
Charset:  
Content-Encoding:  
Last Modified:  
IMAGE INFO!!! →   
Writing to file ::  
D:\project\_x\trunk\dumps\1194882652\_854.gif

Thanks for your help.
