Copy image from a website

I’m trying to copy an image from a website, but can’t seem to get it
right.

I know rio can copy a website in one line, but what about images?
Anyone have a good snippet using open-uri or something?

On Nov 19, 2007 7:00 PM, _Stud [email protected] wrote:

I’m trying to copy an image from a website, but can’t seem to get it
right.

I know rio can copy a website in one line, but what about images?
Anyone have a good snippet using open-uri or something?

web page = (virtual) file
image = (virtual) file

just use open-uri + read and write the contents somewhere.

require ‘open-uri’

File.open(‘logo.gif’, ‘wb’) do |f|
f.write(open(‘http://www.google.com/intl/en_ALL/images/logo.gif’).read)
end

J.

On Nov 20, 2007 2:00 AM, _Stud [email protected] wrote:

I’m trying to copy an image from a website, but can’t seem to get it
right.

I know rio can copy a website in one line, but what about images?
Anyone have a good snippet using open-uri or something?

Using mechanize:

require ‘mechanize’

agent = WWW::Mechanize.new
img = agent.get(“http://www.example.com/image.jpg”)
img.save

will load the JPEG image image.jpg from the site www.example.com and
save it as image.jpg on the local filesystem.

Hi All,

Get all images from given URL

Desktop Application from jazzez

Kindly go through below link and download the EXE file.

Install in Windows machine and enjoy with impressed images

Regards,
P.Raveendran