-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfacebookx.py
More file actions
36 lines (31 loc) · 1.02 KB
/
facebookx.py
File metadata and controls
36 lines (31 loc) · 1.02 KB
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
import mechanize
import cookielib
import re
import urllib
url = 'https://www.facebook.com'
loggedin_title = 'Facebook'
username = '**********'
password = '**********'
browser = mechanize.Browser()
cj = cookielib.LWPCookieJar()
browser.set_cookiejar(cj)
browser.set_handle_robots(False)
browser.addheaders = [('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.6)')]
browser.open(url)
browser.select_form(nr=0)
browser.form["email"] = username
browser.form["pass"] = password
browser.submit()
if browser.title() == loggedin_title:
x = browser.open("https://www.facebook.com/search/str/?q='keywords'")
html = x.read()
x = re.findall('permalink:"(.*?)"', html, re.I|re.M)
for r in x:
print "post: ",r
url2 = "https://www.facebook.com{}".format(r)
y = browser.open(url2)
html2 = y.read()
o = re.findall('<div class="_5pbx userContent" data-ft="{"tn":"K"}">(.*?)<\/div>',html2, re.I|re.M)
print o
else:
print '[-] LOGIN FAILED'