Removed login code, can't be arsed
This commit is contained in:
parent
994c4ee3de
commit
d14ae17ad8
1 changed files with 3 additions and 19 deletions
22
api.py
22
api.py
|
@ -1,28 +1,12 @@
|
|||
import requests
|
||||
import os, getpass, re, pickle, getpass
|
||||
import os, getpass, re, pickle, getpass, json
|
||||
|
||||
class Session():
|
||||
def __init__(self):
|
||||
self.client = requests.Session()
|
||||
|
||||
def set_csrf(self):
|
||||
self.client.headers['x-csrftoken'] = re.search('csrf-token\" content=\"(.*)\">', self.client.get('https://warframe.market').text).group(1)
|
||||
|
||||
def api_request(self, url='/', method='get', **kwargs):
|
||||
return getattr(self.client, method)('https://api.warframe.market/v1' + url, **kwargs)
|
||||
return json.loads(getattr(self.client, method)('https://api.warframe.market/v1' + url, **kwargs).text)
|
||||
|
||||
|
||||
def login(self, force = False):
|
||||
self.set_csrf()
|
||||
if os.path.exists('JWT.pkl') and not force:
|
||||
with open('JWT.pkl', 'rb') as f:
|
||||
self.client.cookies.update(pickle.load(f))
|
||||
else:
|
||||
self.api_request(url='/auth/signin', method='post', json={
|
||||
"auth_type": "cookie",
|
||||
"email": input('Email: '),
|
||||
"password": getpass.getpass("Password: ")
|
||||
})
|
||||
if self.client.cookies.get('JWT'):
|
||||
with open('JWT.pkl', 'wb') as f:
|
||||
pickle.dump(self.client.cookies. f)
|
||||
|
||||
|
|
Loading…
Reference in a new issue