Created
February 23, 2010 14:40
-
-
Save benhutchins/312222 to your computer and use it in GitHub Desktop.
An old script that used to Auto Poke people on Facebook, doesn't work anymore, since their new design
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# User information | |
user = "" ## Your Facebook email address | |
passwd = "" ## Your Facebook password | |
## Edit below this line if you want to | |
# Import some libraries | |
import cookielib, urllib, urllib2 | |
import sys, re, time | |
cj = cookielib.CookieJar() | |
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) | |
def request(url, post_vars = None, headers = False): | |
""" Simple wrapper to run a http request """ | |
global opener | |
# post params | |
if post_vars is None: | |
post = None | |
ctype = 'application/x-www-form-urlencoded' | |
else: | |
post = urllib.urlencode(post_vars) | |
ctype = 'application/x-www-form-urlencoded' | |
# headers | |
if headers is False: | |
if post is None: | |
length = 0 | |
else: | |
length = str(len(post)) | |
headers = { | |
'Host': 'www.facebook.com', | |
'Content-Type': ctype, | |
'Content-Length': length, | |
# Fake a browser | |
'User-Agent': 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.5) Gecko/2008121623 Ubuntu/8.10 (intrepid) Firefox/3.0.5', | |
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', | |
'Accept-Language': 'en-us,en;q=0.5', | |
'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7', | |
'Keep-Alive': '300', | |
'Connection': 'keep-alive', | |
'Referer': 'http://www.facebook.com/' | |
} | |
# run the request | |
req = urllib2.Request(url, post, headers) | |
return opener.open(req).read() | |
# Let's poke some people | |
if __name__ == "__main__": | |
request( "http://www.facebook.com" ) # start cookie | |
response = request( "https://login.facebook.com/login.php", { 'email': user, 'pass': passwd } ) # login | |
while 1: | |
# Search for pokes | |
pokefinder = re.compile('>([^<]*)</a> - <a href="\/poke\.php\?id=([\d]*)\&pokeback=1"') | |
pokes = pokefinder.findall(response) | |
post_form_id = re.compile('post_form_id=([^&]*)') | |
post_form_id = post_form_id.findall(response) | |
post_form_id = post_form_id[0] | |
if len(pokes) == 0: | |
print "No pokes." | |
else: | |
# Poke people back | |
for poke in pokes: | |
print "Poking %s (%i)" % (poke[0], int(poke[1])) | |
request( "http://www.facebook.com/poke.php", { | |
'id': poke[1], | |
'uid': poke[1], | |
'confirmed': 1, | |
'pokeback': 1, | |
'post_form_id': post_form_id, | |
'post_form_id_source': 'AsyncRequest', | |
} ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment