Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- s = requests.Session()
- # GET
- url = _build_sc_url('/profile/signin', secure=True)
- r = s.get(url)
- soup = BeautifulSoup(r.text)
- selector = '#formLogin input[name=__RequestVerificationToken]'
- verif_token = soup.select(selector)[0].attrs['value']
- # POST
- headers = {
- 'X-Requested-With': 'XMLHttpRequest',
- 'Content-Type': 'application/json', # remove when using json=...
- }
- payload = {
- '__RequestVerificationToken': verif_token,
- 'login': 'rootri',
- 'password': 'dM20kzqhv5',
- 'rememberme': True,
- }
- url = _build_sc_url('/profile/signincompact', secure=True)
- # r = s.post(url, headers=headers, json=payload, allow_redirects=False)
- r = s.post(url, headers=headers, data=json.dumps(payload),
- allow_redirects=False)
- if not r.json()['Status']:
- raise LoginFailureError(r.json()['ErrorText'])
- self._sc_bot.sc_cookies = r.cookies
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement