Created
September 15, 2015 09:01
-
-
Save borewicz/2c62ece6b21fa8516fa2 to your computer and use it in GitHub Desktop.
kaczor masz przejebane
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
import re | |
import requests | |
from lxml import html | |
import time | |
import json | |
from account_info import username, password, thread_id, kaczor_id | |
s = requests.Session() # zbiornik na kukizy | |
s.get('https://facebook.com/') | |
site = s.get('https://facebook.com/') | |
tree = html.fromstring(site.text) | |
data = { | |
'email': username, | |
'pass': password, | |
} | |
for item in tree.xpath('//form[@id="login_form"]/input[@type="hidden"]'): | |
if item.attrib['value']: | |
data[item.attrib['name']] = item.attrib['value'] | |
response = s.post('http://www.facebook.com/login.php', data=data, | |
cookies={ | |
'_js_datr': re.findall(r'datr","([^"]+)"', site.text)[0] | |
}) | |
fb_dtsg = re.findall('fb_dtsg.+?value="([^"]+)"', response.text)[0] | |
message_data = { | |
'message_batch[0][action_type]': 'ma-type:log-message', | |
'message_batch[0][timestamp]': "%d000" % int(time.time()), | |
'message_batch[0][timestamp_time_passed]': '0', | |
'message_batch[0][is_unread]': 'false', | |
'message_batch[0][is_forward]': 'false', | |
'message_batch[0][is_filtered_content]': 'false', | |
'message_batch[0][is_filtered_content_bh]': 'false', | |
'message_batch[0][is_filtered_content_account]': 'false', | |
'message_batch[0][is_filtered_content_quasar]': 'false', | |
'message_batch[0][is_filtered_content_invalid_app]': 'false', | |
'message_batch[0][is_spoof_warning]': 'false', | |
'message_batch[0][source]': 'source:titan:web', | |
'message_batch[0][log_message_type]': 'log:subscribe', | |
'message_batch[0][log_message_data][added_participants][0]': 'fbid:' + kaczor_id, | |
'message_batch[0][offline_threading_id]': '6042026089660994181', # nie ma znaczenia xD | |
'message_batch[0][message_id]': '6042026089660994181', | |
'message_batch[0][thread_fbid]': str(thread_id), | |
'__a': '1', | |
'fb_dtsg': fb_dtsg | |
} | |
def check_kaczor_absence(): | |
req = s.post("https://www.facebook.com/ajax/mercury/threadlist_info.php", | |
data={ | |
'fb_dtsg': fb_dtsg, | |
'__a': '1', | |
"inbox[offset]": "0", | |
"inbox[limit]": "200" | |
}) | |
threads = json.loads(req.text[9:])['payload']['threads'] | |
for t in threads: | |
if t['thread_fbid'] == thread_id: | |
return 'fbid:' + str(kaczor_id) in t['participants'] | |
while True: | |
if not check_kaczor_absence(): | |
# print('guwno') | |
response = s.post('https://www.facebook.com/ajax/mercury/send_messages.php', data=message_data) | |
if response.status_code != 200: | |
print('no chyba kurwa nie: %d' % response.status_code) | |
# time.sleep(2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment