Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import re
- with requests.Session() as s:
- username = 'xxx@xxx.com'
- password = 'xxx'
- login_url = 'https://xxx.com`'
- r = s.get(login_url)
- html = r.text
- # Parse out the username field's name
- username_regex = re.compile('\<input value="" id="username" type="text" name="(.*)"\>')
- match = username_regex.search(html)
- username_id = match.group(1)
- print("UID: " + username_id)
- # Parse out the password field's name
- pw_regex = re.compile('\<input value="" id="password" type="password" name="(.*)"\>')
- match = pw_regex.search(html)
- pw_id = match.group(1)
- print("PWID: " + pw_id)
- # Now start an actual session where we log in
- payload = {
- username_id: username,
- pw_id: password
- }
- p = s.post(login_url, data=payload)
- # An authorised request.
- r = s.get('https://xxx.com/logged_in_page/')
- print(r.text)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement