Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import requests
- import urllib
- from lxml import etree
- session = requests.Session()
- tokenRequest = session.get('http://localhost/Account/Login')
- parser = etree.HTMLParser()
- tree = etree.fromstring(tokenRequest.text, parser)
- verificationToken = tree.xpath('//form//input[@name="__RequestVerificationToken"]/@value')[0]
- sessionCookies = tokenRequest.cookies
- payload = { 'Email' : 'somerandomemail@somedomain' , 'Password' : 'somerandompassword', '__RequestVerificationToken' : verificationToken}
- raw = urllib.urlencode(payload)
- headers = {'Content-Type': 'text/html; charset=utf-8','Origin':'http://localhost','Referer':'http://localhost/Account/Login'}
- plateRequest = session.post('http://localhost/Account/Login', data=raw, cookies=sessionCookies, headers=headers)
- print plateRequest.text
- #print sessionCookies
- #print raw
- > <h1 class="text-danger">Error.</h1> <h2 class="text-danger">An error
- > occurred while processing your request.</h2> <h2
- > class="text-danger">Or maybe your session has ended, please <a
- > href="~/Account/Login">Login</a> again.</h2>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement