How to download an image from flickr
Mar 11
2009
2009
Comments Off
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]) |