Created
May 5, 2014 02:08
-
-
Save fdb713/434267e7b6e6a03db82b to your computer and use it in GitHub Desktop.
Facebook Autorepoke
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
#!/usr/bin/env python2 | |
# -*- coding: utf-8 -*- | |
# Usage: chmod +x ./facebook_autorepoke.py; ./facebook_autorepoke.py email password | |
import requests | |
import sys | |
import re | |
from time import sleep | |
from pyquery import PyQuery as pq | |
url_login = "https://www.facebook.com/login.php" | |
url_base = "https://www.facebook.com" | |
timeout = 3 | |
def main(): | |
if len(sys.argv) < 3: | |
print("Arguments missing. Usage: python facebook_autorepoke.py email password.") | |
sys.exit(1) | |
data = {} | |
data["email"] = sys.argv[1] | |
data["pass"] = sys.argv[2] | |
headers= { | |
'Origin': url_base, | |
'Referer': "%s/" % url_base, | |
'User-Agent':'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.57 Safari/537.36', | |
} | |
s = requests.Session() | |
r = s.post(url_login, data=data, headers=headers) | |
sleep(1) | |
r = s.post(url_login, data=data, headers=headers) | |
if re.findall("re-enter your password", r.content): | |
print "Login failed." | |
return -1 | |
while True: | |
url_poke_backs = get_poke_back(s.get("https://www.facebook.com/pokes").content) | |
print url_poke_backs | |
for x in url_poke_backs: | |
print x | |
rr = s.get(x) | |
if rr.status_code == 200: | |
print("Poked back.") | |
sleep(timeout) | |
def get_poke_back(content): | |
d = pq(content) | |
poke_back_nodes = [ x for x in d("a._42ft._4jy0._4jy3._4jy1.selected") if not "data-gt" in x.attrib ] | |
return [ url_base + x.attrib["ajaxify"] for x in poke_back_nodes ] | |
if __name__ == "__main__": | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment