Picture

L

Lex Williams

Newb said:
How to download picture from the particular url ?
THanks Much

using Mechanize you could do it like this ( if I remember correctly ) :

agent = WWW::Mechanize.new
link = some_site.com/whatever.jpg
agent.get(link).save_as(File.basename(link))
 
N

Newb Newb

Lex said:
using Mechanize you could do it like this ( if I remember correctly ) :

agent = WWW::Mechanize.new
link = some_site.com/whatever.jpg
agent.get(link).save_as(File.basename(link))

How about implementing using 'open uri'
Help needed..
 
L

Lex Williams

Newb said:
How about implementing using 'open uri'
Help needed..

File.open("some_pic.jpg") do |file|
file.puts open("some_site.com/some_pic.jpg").read
end
 
T

Tucano

require 'open-uri'

imgurl = "URL to photo"
photo = open(imgurl,"rb") { |io| io.read }
 

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

Forum statistics

Threads
473,792
Messages
2,569,639
Members
45,351
Latest member
RoxiePulli

Latest Threads

Top