Save image in local machine

  • Thread starter Raveendran Perumalsamy
  • Start date
H

Heesob Park

Hi,

2009/4/15 Raveendran Perumalsamy said:
Hi All,


I want to save this image in my local machine with ruby code

https://mail.google.com/mail/help/images/logo.gif

Note: I did with Watir gem. But I want to do it another simple way.

require 'net/https'
require 'uri'

url = 'https://mail.google.com/mail/help/images/logo.gif'
uri = URI.parse(url)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true if uri.scheme == "https"
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
http.start {
http.request_get(uri.path) {|res|
File.open(File.basename(uri.path),'wb') { |f|
f.write(res.body)
}
}
}


Regards,

Park Heesob
 
R

Raveendran Perumalsamy

Heesob said:
Hi,



require 'net/https'
require 'uri'

url = 'https://mail.google.com/mail/help/images/logo.gif'
uri = URI.parse(url)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true if uri.scheme == "https"
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
http.start {
http.request_get(uri.path) {|res|
File.open(File.basename(uri.path),'wb') { |f|
f.write(res.body)
}
}
}


Regards,

Park Heesob

Hi Park,

Thanks for your code and also I need to save the image in Given path
like c:\raveendran\

Where I can add this path in above program ?

Thanks
P.Raveendran
http://raveendran.wordpress.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top