-
-
Save BenjaminHoegh/e78d0f7fb2ac53ce1e9355a32bab6e1f to your computer and use it in GitHub Desktop.
simple facebook poke bot
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_Username = "your_email" | |
Facebook_Password = "your_password" | |
from sys import exit, stdout | |
import traceback | |
import mechanize | |
import time | |
import os | |
from bs4 import BeautifulSoup as soup | |
import re | |
MAX_DELAY = 5 | |
MIN_DELAY = 2 | |
delay = MAX_DELAY | |
totalPokes = 0 | |
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) | |
class Printer(): | |
def __init__ (self,output): | |
stdout.write("\r"+output+"\033[K") | |
stdout.flush() | |
def wait_for_time(delay): | |
while (delay >= 0): | |
status = str("Checking again in " + str(delay) + " seconds") | |
Printer(status) | |
delay -= 1 | |
time.sleep(1) | |
def begin_checking_for_pokes (): | |
while True: | |
try: | |
browser.open("http://m.facebook.com/pokes") | |
for l in browser.links(text_regex = "Poke Back"): | |
print ('we found a poke!') | |
s = soup(browser.response()) | |
name = s.body.find("div", class_='bo') | |
print (name.get_text()) | |
browser.follow_link(text_regex="Poke Back",nr=0) | |
print ("Poked Back!") | |
except: | |
print ("There was some sort of error....") | |
print (traceback.format_exc()) | |
exit() | |
wait_for_time(MAX_DELAY) | |
def login_to_facebook (): | |
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() | |
s = soup(browser.response()).body.findAll(text='Your password was incorrect.') | |
if 'Your password was incorrect.' in s: | |
print ('error, check your password') | |
else: | |
begin_checking_for_pokes() | |
login_to_facebook(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment