-
Notifications
You must be signed in to change notification settings - Fork 155
Expand file tree
/
Copy pathhelpers.py
More file actions
38 lines (34 loc) · 1.46 KB
/
helpers.py
File metadata and controls
38 lines (34 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import robobrowser
import re
import json
import os
import random
MOBILE_USER_AGENT = "Mozilla/5.0 (Linux; U; en-gb; KFTHWI Build/JDQ39) AppleWebKit/535.19 (KHTML, like Gecko) Silk/3.16 Safari/535.19"
FB_AUTH = "Insert your FB authentication token here"
def get_access_token(email, password):
s = robobrowser.RoboBrowser(user_agent=MOBILE_USER_AGENT, parser = "lxml")
s.open(FB_AUTH)
##submit login form##
f = s.get_form()
f["pass"] = password
f["email"] = email
s.submit_form(f)
##click the 'ok' button on the dialog informing you that you have already authenticated with the Tinder app
f = s.get_form()
s.submit_form(f, submit=f.submit_fields['__CONFIRM__'])
##get access token from the html response##
access_token = re.search(r"access_token=([\w\d]+)", s.response.content.decode()).groups()[0]
# print s.response.content.decode()
return access_token
def get_login_credentials():
print("Checking for credentials..")
if os.path.exists('auth.json'):
print("Auth.json existed..")
with open("auth.json") as data_file:
data = json.load(data_file)
if "email" in data and "password" in data and "FBID" in data:
return (data["email"], data["password"], data["FBID"])
else:
print ("Invalid auth.json file")
print ("Auth.json missing or invalid. Please enter your credentials.")
return (input("Enter email ..\n"), input("Enter password..\n"))