-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfbfrndspics.py
58 lines (50 loc) · 2.06 KB
/
fbfrndspics.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import requests
import json
TOKEN = '' #Insert access token here.
def get_data():
query = ('SELECT first_name,sex,pic_big FROM user WHERE uid in (SELECT uid2 FROM friend WHERE uid1 = me())')
payload = {'q': query, 'access_token': TOKEN}
r = requests.get('https://graph.facebook.com/fql', params=payload)
result = json.loads(r.text)
return result['data']
def Download_pics(xs):
choice = raw_input("Download Options:\n1.All\n2.Specific\nSex\n\t3.Male\n\t4.Female\n\nEnter Your Choice: ")
if choice == '1':
for x in xs:
r = requests.get(x['pic_big'], stream=True)
file = open(x['first_name'] + '.jpg', 'wb')
for block in r.iter_content(1024):
file.write(block)
print
"Successfully Downloaded %s" % x['first_name']
elif choice == '3':
for x in xs:
if x['sex'] == 'male':
r = requests.get(x['pic_big'], stream=True)
file = open(x['first_name'] + '.jpg', 'wb')
for block in r.iter_content(1024):
file.write(block)
print
"Successfully Downloaded %s" % x['first_name']
elif choice == '4':
for x in xs:
if x['sex'] == 'female':
r = requests.get(x['pic_big'], stream=True)
file = open(x['first_name'] + '.jpg', 'wb')
for block in r.iter_content(1024):
file.write(block)
print
"Successfully Downloaded %s" % x['first_name']
else:
for x in xs:
msg = 'Do you want to download %s Profile pic?(Y/N)' % x['first_name']
spec = raw_input(msg)
if spec == 'Y':
r = requests.get(x['pic_big'], stream=True)
file = open(x['first_name'] + '.jpg', 'wb')
for block in r.iter_content(1024):
file.write(block)
print
"Successfully Downloaded %s" % x['first_name']
if __name__ == '__main__':
Download_pics(get_data())