
Hacking Friends Photos PyLadies version
By:
fmasanori on
Sep 29th, 2011 | syntax:
Python | size: 1.20 KB | hits: 1,277 | expires: Never
import urllib.request
import json
'''
0. pyLadies version of Hacking Facebook Photos
1. Install Python 3.x (batteries included yay)
2. Log into https://developers.facebook.com/docs/reference/api/
3. Copy Friends Link with access_token
4. Run
Obs.: try advanced hacking in this links
https://github.com/facebook/python-sdk
https://github.com/facebook/fbconsole
https://github.com/finiteloop/socialcookbook
'''
def get_friends():
url = 'Copy the friends link here'
resp = urllib.request.urlopen(url).read()
data = json.loads(resp.decode('utf-8'))
return data['data']
def picture(id_friend):
url = 'https://graph.facebook.com/'+ id_friend + '/picture?type=large'
return urllib.request.urlopen(url).read()
def female(id_friend):
url = 'https://graph.facebook.com/'+ id_friend
resp = urllib.request.urlopen(url).read()
data = json.loads(resp.decode('utf-8'))
if 'gender' not in data: return False
return data['gender'] == 'female'
def download_pics(friends):
for f in friends:
if female(f['id']):
print (f['name'])
file = open (f['name']+'.jpg', 'wb')
file.write(picture(f['id']))
file.close()
download_pics(get_friends())