Created
February 6, 2013 12:37
-
-
Save jplattel/4722298 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/python | |
import os | |
import urllib | |
import simplejson as json | |
import time | |
#params | |
def fetchPage(i): | |
url = "https://api.mobypicture.com/" | |
apikey = "jhIMirqEUScIcDH6" | |
params = urllib.urlencode({"action": "getUserMedia", "key": apikey, "username": "jplattel", "format": "json", "page": i}) | |
u = urllib.urlopen(url + "?" + params) | |
response = json.loads(u.read()) | |
l = [] | |
for result in response['results']: | |
#print result['title'] | |
#print result['created_on'] | |
g = [result['title'],result['media']['url_full'], result['created_on']] | |
l.append(g) | |
return l | |
def getImage(url, name): | |
image = urllib.urlopen(url).read() | |
name = name.replace('/','_') | |
f = open(name, "wb") | |
f.write(image) | |
f.close() | |
print "Saving picture: " + name | |
def paging(i): | |
total = [] | |
for i in range(1,i): | |
data = fetchPage(i) | |
for item in data: | |
total.append(item) | |
time.sleep(5) | |
return total | |
photos = paging(35) | |
for photo in photos: | |
getImage(photo[1], photo[2] + " " + photo[0] + ".jpg") | |
time.sleep(3) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment