Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Save image in local machine
Raveendran Jazzez
4/15/2009 5:34:00 AM
Hi All,
I want to save this image in my local machine with ruby code
https://mail.google.com/mail/help/image...
Note: I did with Watir gem. But I want to do it another simple way.
Thanks in advance,
P.Raveendran
http://raveendran.wor...
--
Posted via
http://www.ruby-...
.
3 Answers
Heesob Park
4/15/2009 6:11:00 AM
0
Hi,
2009/4/15 Raveendran Perumalsamy <jazzezravi@gmail.com>:
> Hi All,
>
>
> I want to save this image in my local machine with ruby code
>
>
https://mail.google.com/mail/help/image...
>
> 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/image...
'
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
Raveendran Jazzez
4/15/2009 6:29:00 AM
0
Heesob Park wrote:
> Hi,
>
> 2009/4/15 Raveendran Perumalsamy <jazzezravi@gmail.com>:
>> Hi All,
>>
>>
>> I want to save this image in my local machine with ruby code
>>
>>
https://mail.google.com/mail/help/image...
>>
>> 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/image...
'
> 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.wor...
--
Posted via
http://www.ruby-...
.
Raveendran Jazzez
4/15/2009 6:39:00 AM
0
Hi park,
I got the solution to change the line like this
File.open("c:\\TML\\1.gif",'wb')
Thanks.
P.Raveendran
http://raveendran.wor...
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Save image in local machine
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password