fmasanori

Hacking Friends Profile Pictures with Python

Sep 27th, 2011
508
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.90 KB | None | 0 0
  1. import urllib.request
  2. import json
  3. '''
  4. 1. Install Python 3.x (batteries included yay)
  5. 2. Log into https://developers.facebook.com/docs/reference/api/
  6. 3. Copy Friends Link with access_token
  7. 4. Run
  8. Obs.: try advanced hacking in this links
  9.   https://github.com/facebook/python-sdk
  10.   https://github.com/facebook/fbconsole
  11.   https://github.com/finiteloop/socialcookbook
  12. '''
  13.  
  14. def get_friends():
  15.   url = 'Paste Friends Link here with your access_token'
  16.   resp = urllib.request.urlopen(url).read()
  17.   data = json.loads(resp.decode('utf-8'))
  18.   return data['data']
  19.  
  20. def picture(id_friend):
  21.   url = 'https://graph.facebook.com/'+ id_friend + '/picture?type=large'
  22.   return urllib.request.urlopen(url).read()
  23.  
  24. def download_pics(friends):
  25.   for f in friends:
  26.     print (f['name'])
  27.     file = open (f['name']+'.jpg', 'wb')
  28.     file.write(picture(f['id']))
  29.     file.close()
  30.  
  31. download_pics(get_friends())
Add Comment
Please, Sign In to add comment