Created
January 1, 2014 06:15
-
-
Save Justasic/8205593 to your computer and use it in GitHub Desktop.
Facebook autopoker (based on the original script from https://github.com/linuz/Facebook-Auto-Poker)
This file contains 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/python | |
############################################################################# | |
# Facebook Auto-Poker Python V1.5 # | |
# # | |
# Written By: Dennis Linuz <dennismald@gmail.com> # | |
# Auto-pokes anyone on Facebook that has poked you with a Variable Delay # | |
# and a file to specify which Facebook IDs NOT to poke (blockPokes.txt) # | |
############################################################################# | |
FACEBOOK_USERNAME = "" | |
FACEBOOK_PASSWORD = "" | |
import mechanize, time, os, sys, curses, re | |
from BeautifulSoup import BeautifulSoup as soup | |
MAX_DELAY = 5 | |
delay = MAX_DELAY | |
totalPokes = 0 | |
stdscr = None | |
row = 0 | |
def _print(string): | |
global row | |
y, x = stdscr.getmaxyx() | |
row += 1 | |
if row > (y-2): | |
row -= 2 | |
stdscr.addstr(row%y-1, 1, string.encode('utf-8')) | |
stdscr.refresh() | |
def PrintTotalPokes(): | |
global totalPokes | |
y, x = stdscr.getmaxyx() | |
RED_TEXT = 1 | |
stdscr.hline(y-2, 0, '_', x-1) | |
curses.init_pair(RED_TEXT, curses.COLOR_RED, curses.COLOR_BLACK) | |
stdscr.addstr(y-1, 0, u"Total Pokes: %d" % totalPokes, curses.color_pair(RED_TEXT)) | |
stdscr.refresh() | |
def FacebookPoker(stdscr): | |
global delay, totalPokes, MAX_DELAY | |
browser = mechanize.Browser() | |
browser.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.61')] | |
browser.set_handle_robots(False) | |
browser.open("http://m.facebook.com/pokes") | |
browser._factory.is_html = True | |
browser.select_form(nr=0) | |
browser.form['email'] = FACEBOOK_USERNAME | |
browser.form['pass'] = FACEBOOK_PASSWORD | |
browser.submit() | |
browser._factory.is_html = True | |
_print("Hello!") | |
while True: | |
try: | |
tempPokeCount = 0 | |
browser.open("http://m.facebook.com/pokes") | |
browser._factory.is_html = True | |
s = soup(browser.response().get_data()) | |
pokes = s.findAll('div', id=re.compile('poke_live_item_\d+')) | |
for p in pokes: | |
_print("Poked %s" % p.find('img')['alt']) | |
link = browser.find_link(url=p.findAll('a')[2]['href']) | |
browser.follow_link(link) | |
browser.back() | |
tempPokeCount += 1 | |
totalPokes += 1 | |
if (tempPokeCount != 0 and delay > 1): delay /= 2 | |
if (tempPokeCount == 0 and delay < MAX_DELAY): delay *= 2 | |
#for i in xrange(0, 25): | |
# _print("herp derp %d" % i) | |
PrintTotalPokes() | |
except: | |
_print("There was some sort of error :(") | |
time.sleep(delay) | |
if __name__ == "__main__": | |
stdscr = curses.initscr() | |
curses.noecho() | |
curses.cbreak() | |
stdscr.keypad(True) | |
stdscr.nodelay(True) | |
row = 0 | |
pad = None | |
curses.start_color() | |
yx = stdscr.getmaxyx() | |
try: | |
PrintTotalPokes() | |
FacebookPoker(stdscr) | |
except curses.error as e: | |
print "some kind of curses error: ", e | |
raise | |
except: | |
raise | |
finally: | |
stdscr.keypad(False) | |
stdscr.nodelay(False) | |
curses.nocbreak() | |
curses.echo() | |
curses.endwin() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment