Skip to content

Instantly share code, notes, and snippets.

@maluta
Created March 27, 2010 23:15
Show Gist options
  • Save maluta/346413 to your computer and use it in GitHub Desktop.
Save maluta/346413 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
# Tiago Maluta
# License: GPLv3
import simplejson
import urllib
f = open("download.sh","w+")
f.write("#!/bin/sh\n")
i = 0
#for i in range(0,1200,100):
while True:
url_base="http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20flickr.photos.search(" + str(i) + "%2C" + str(i+100) +")%20where%20tags%3D%22brhackday%22%20and%20license%3D%221%2C2%2C3%2C4%2C5%2C6%22&format=json"
rest = simplejson.load(urllib.urlopen(url_base))['query']
if rest['count'] == '0':
f.close()
exit()
photos = rest['results']['photo']
for photo in photos:
id = photo['id']
owner = photo['owner']
d = "curl -s http://www.flickr.com/photos/%s/%s/sizes/o | egrep \"<p><img src=\" | sed 's/<p>//g ; s/<br \/>//g ; s/<\/p>//g ; s/<img src=\"//g ; s/\" \/>//g' | xargs wget ;" % (owner, id)
f.write(d+'\n')
i += 100
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment