-
Notifications
You must be signed in to change notification settings - Fork 3
/
photo.py
49 lines (41 loc) · 1.48 KB
/
photo.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
import os, re, requests
cookies = {
"c_user": "",
"xs": ""
}
friend_id = ""
host = "https://mbasic.facebook.com"
def load_photo(input_url):
req = requests.Session()
offset = 0
while True:
url = "{}{}".format(input_url, offset)
res = req.get(url, cookies=cookies)
html = res.text
match = re.findall(r"/photo.php\?fbid=([0-9]*)&", html)
if match:
for m in match:
f = open("{}/{}.jpg".format(friend_id, m),"wb")
res = req.get("{}/photo/view_full_size/?fbid={}".format(host, m), cookies=cookies)
html = res.text
z = re.search(r"a href=\"(.*?)\"", html)
if z:
url = str(z.groups()[0]).replace("&", "&")
if "https://" not in url:
continue
res = req.get(url, cookies=cookies)
f.write(res.content)
f.close()
else:
continue
offset+=12
print(offset)
else:
break
if __name__ == "__main__":
if not os.path.exists(friend_id):
os.makedirs(friend_id)
url_photo_tag = "{}/{}/photoset/pb.{}.-2207520000../?owner_id={}&offset=".format(host, friend_id, friend_id, friend_id)
url_photo_upload = "{}/{}/photoset/t.{}/?owner_id={}&offset=".format(host, friend_id, friend_id, friend_id)
load_photo(url_photo_tag)
load_photo(url_photo_upload)