[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Screen Scraping an Image

Sean Kenney

12/3/2007 9:10:00 PM

How do you screen scrape an image off of a web page?
4 Answers

Phrogz

12/3/2007 9:20:00 PM

0

On Dec 3, 2:10 pm, Sean Kenney <skenne...@gmail.com> wrote:
> How do you screen scrape an image off of a web page?

You find the URL of the image (possibly resolving a relative URL
against the absolute URL of the page) and then ask the web server to
send you that file over http.

Robert Citek

12/3/2007 10:25:00 PM

0

On Dec 3, 2007 3:24 PM, Phrogz <phrogz@mac.com> wrote:
> On Dec 3, 2:10 pm, Sean Kenney <skenne...@gmail.com> wrote:
> > How do you screen scrape an image off of a web page?
>
> You find the URL of the image (possibly resolving a relative URL
> against the absolute URL of the page) and then ask the web server to
> send you that file over http.

I suspect Sean is asking, what's the ruby way of doing a wget?

For example:

wget http://www.ruby-lang.org/image...

Regards,
- Robert

Sean Kenney

12/3/2007 10:37:00 PM

0

Here's a script I found at http://www.rubynoob.com/articles/2006/8/21/how-to-download-files-with-a-r...

require 'net/http'

Net::HTTP.start("static.flickr.com") { |http|
resp = http.get("/92/218926700_ecedc5fef7_o.jpg")
open("fun.jpg", "wb") { |file|
file.write(resp.body)
}
}

Vitor Peres

12/5/2007 6:26:00 PM

0

Note: parts of this message were removed by the gateway to make it a legal Usenet post.

On Dec 3, 2007 8:39 PM, Sean Kenney <skenney26@gmail.com> wrote:

> Here's a script I found at
> http://www.rubynoob.com/articles/2006/8/21/how-to-download-files-with-a-r...
>
> require 'net/http'
>
> Net::HTTP.start("static.flickr.com") { |http|
> resp = http.get("/92/218926700_ecedc5fef7_o.jpg")
> open("fun.jpg", "wb") { |file|
> file.write(resp.body)
> }
> }
>
>
Or maybe shorter:

require 'open-uri'

open('image.jpg', 'wb') {|f| f << open('
http://www.domain.com/imag...).read }