How to download an image from flickr

Mar 11
2009

I wasn’t able to download a photo from flickr. It happened to be 1px transparent image over the other. Here is a simple scaper in cases of such “protection”:

1
2
3
4
5
6
7
8
9
10
11
12
require 'rubygems'
require 'www/mechanize'
 
url = 'http://www.flickr.com/photos/46457493@N00/3162339409/in/set-72157612102050814/'
 
my_id = url.split("/")[-3]
agent  = WWW::Mechanize.new
page   = agent.get(url)
 
url   = page.search("//div[@id='photoImgDiv#{my_id}']/img").attr('src')
 
agent.get(url).save_as((File.basename(url)).split("?")[0])

Comments are closed.

Calendar

March 2009
M T W T F S S
« Feb   May »
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

Tags