-
Notifications
You must be signed in to change notification settings - Fork 1
/
status.py
executable file
·53 lines (44 loc) · 1.25 KB
/
status.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
#!/usr/bin/env python
import sys
import mechanize
import re
import HTMLParser
from BeautifulSoup import BeautifulSoup
FB_URL = "https://m.facebook.com"
browser = mechanize.Browser()
h = HTMLParser.HTMLParser()
browser.set_handle_robots(False)
browser.open(FB_URL)
browser._factory.is_html = True
browser.select_form(nr=0)
browser.form['email'] = sys.argv[1]
browser.form['pass'] = sys.argv[2]
browser.submit()
x = 0
while x != 3:
input = raw_input('''Please select an option:
To update your status enter 1
To view your friends' statuses enter 2
To quit this script enter 3\n''')
x = int(input)
if x == 1:
status = raw_input('Please enter the status you would like to post.\n')
browser._factory.is_html = True
browser.select_form(nr=1)
browser.form['status'] = status
browser.submit()
elif x == 2:
page = browser.open(FB_URL)
soup = BeautifulSoup(page.read())
list = soup.findAll('div', {'class': re.compile('c[abu]') })
for l in list:
a = l.find('div', {'data-sigil':'mfeed_pivots_message feed-story-highlight-candidate'})
if a:
name = l.find('a', text=True)
status = a.find('span', text=True)
if name and status:
print h.unescape(name)
print h.unescape(status)
print '\n'
elif x != 3:
print 'invalid input'