forked from ProjectBucky/bucky_latest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
facebook.py
59 lines (55 loc) · 2.03 KB
/
facebook.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
59
import sys
from robobrowser import RoboBrowser
fburl = "https://mbasic.facebook.com/"
import random
DEBUG=False
def dbg(message):
if DEBUG:
print(message)
return
else:
return
fbbrowser = RoboBrowser(history=True,parser="html.parser")
def login(username,password):
global fbbrowser
USER_AGENTS = ('Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:11.0) Gecko/20100101 Firefox/11.0',
'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100 101 Firefox/22.0',
'Mozilla/5.0 (Windows NT 6.1; rv:11.0) Gecko/20100101 Firefox/11.0',
('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/536.5 (KHTML, like Gecko) '
'Chrome/19.0.1084.46 Safari/536.5'),
('Mozilla/5.0 (Windows; Windows NT 6.1) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.46'
'Safari/536.5'),)
fbbrowser.session.headers['User-Agent'] = random.choice(USER_AGENTS)
dbg("Pointing browser to facebook.com...")
fbbrowser.open('https://mbasic.facebook.com/')
login_form=fbbrowser.get_form(0)
dbg("Typing username...")
login_form['email']=username
dbg("Typing password...")
login_form['pass']=password
dbg("Logging in....")
fbbrowser.submit_form(login_form)
try:
links=fbbrowser.get_links()
if(links[0].text=='Not Now'):
dbg("Remember browser...")
form=fbbrowser.get_form(0)
fbbrowser.submit_form(form)
except Exception as e:
pass
links=fbbrowser.get_links()
for link in links:
if(link.text=='Chat'):
print("Login success...")
return 0
dbg("login failure...")
return 1
def post(post_text):
global fbbrowser
fbbrowser.open("https://www.facebook.com/sharer/sharer.php?u=bucky.16mb.com&_rdr")
form = fbbrowser.get_form(0)
form["xhpc_message"]=post_text
fbbrowser.submit_form(form)
if __name__ == '__main__':
login("dinkan","dinkan")
post(" ".join(sys.argv[1:]))