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.
···
On Dec 3, 2:10 pm, Sean Kenney <skenne...@gmail.com> wrote:
How do you screen scrape an image off of a web page?
I suspect Sean is asking, what's the ruby way of doing a wget?
For example:
wget http://www.ruby-lang.org/images/logo.gif
Regards,
- Robert
···
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.
Here's a script I found at http://www.rubynoob.com/articles/2006/8/21/how-to-download-files-with-a-ruby-script
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('
Website Domain Names, Online Stores & Hosting | Domain.com).read }
···
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-ruby-scriptrequire '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)
}
}