Created
December 17, 2010 02:36
-
-
Save Arthraim/744404 to your computer and use it in GitHub Desktop.
get all avatars from renjian.com
This file contains 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
import urllib | |
import simplejson | |
i = 0 | |
breaki = 0 | |
while i >= 0: | |
i = i + 1 | |
print '' | |
rnjn_url = 'http://api.renjian.com/' | |
user_url = rnjn_url + 'users/show.json?id=' + unicode(i) | |
print user_url | |
retval = urllib.urlopen(user_url) | |
json = retval.read() | |
data = simplejson.loads(json, encoding='UTF-8') | |
if data.has_key('message'): | |
breaki = breaki + 1 | |
if breaki >= 100: | |
break | |
continue | |
breaki = 0 | |
img_url = unicode(data['profile_image_url']) | |
print img_url | |
if img_url == 'http://renjian.com/images/buddy_icon/120x120.jpg' or img_url == 'http://renjian.com/images/buddy_icon/g120x120.jpg': | |
continue | |
else: | |
path = '/home/arthur/rjavatars/' + unicode(i) + '_' + unicode(data['screen_name']) + '.jpg' | |
data = urllib.urlopen(img_url).read() | |
f = file(path, 'wb') | |
f.write(data) | |
f.close() | |
print path | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment