-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfbfrnd.py
51 lines (39 loc) · 1.36 KB
/
fbfrnd.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 http.cookiejar
import urllib.request
import requests
import bs4
# Store the cookies and create an opener that will hold them
cj = http.cookiejar.CookieJar()
opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj))
# Add our headers
opener.addheaders = [('User-agent', 'dfdf')]
# Install our opener (note that this changes the global opener to the one
# we just made, but you can also just call opener.open() if you want)
urllib.request.install_opener(opener)
# The action/ target from the form
authentication_url = 'https://m.facebook.com/login.php'
# Input parameters we are going to send
payload = {
'email': '[email protected]',
'pass': 'subscribemychannel'
}
# Use urllib to encode the payload
data = urllib.parse.urlencode(payload).encode("utf-8")
# Build our Request object (supplying 'data' makes it a POST)
req = urllib.request.Request(authentication_url, data)
# Make the request and read the response
resp = urllib.request.urlopen(req)
contents = resp.read()
print(contents)
url = "https://m.facebook.com/pince.chandra/friends"
data = requests.get(url, cookies=cj)
soup = bs4.BeautifulSoup(data.text, 'html.parser')
print(soup.prettify())
z = 0
for i in soup.find_all('a'):
if z>16:
if i.text.lower()=="see more friends":
break
elif i.text!= "Add Friend":
print(i.text)
z = z+1