import urllib
import simplejson
def getProfilePicUrl(user_id):
api_query = urllib.urlopen('https://graph.facebook.com/'+user_id)
dict = simplejson.loads(api_query.read())
return dict['picture']
When we visit a facebook profile the user id is displayed in the address of the page. This is the address of the cocacola page, in red the user id of coca cola:
http://www.facebook.com/profile.php?id=40796308305
now can use the id to save the profile picture of coca cola.
pic_url = getProfilePicUrl('40796308305')
pic = urllib.urlopen(pic_url) # retrieve the picture
f = open("cocacola.jpg","wb")
f.write(pic.read()) # save the pic
f.close()
The script will save the picture on the disk. Warning: coca cola has a public profile, non-public profile need authentication.
