Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import time
- with requests.Session() as c:
- #Define my varibles
- url = 'http://itsupport.work.com.au/scp/login.php'
- userName = 'my.name'
- passWord = 'Pa$$word123'
- do = 'scplogin'
- submit = " "
- #Navigate to page to get token/cookie (Cookie's name = OSTSESSID , csrftoken name = __CSRFToken__ )
- #If I use this cookie name, the login fails AND if I use __CSRFToken__ as the cookie name I get an error
- #However I think I'm suppose to be using this cookie name?
- c.get(url)
- time.sleep(3)
- csrftoken = c.cookies['OSTSESSID']
- #Debug line
- print(csrftoken)
- #Form data that I'm sending to the login.php page (note: I've put it in the exact order the data is being sent)
- login_data = {"__CSRFToken__": csrftoken, 'do': do, 'userid': userName, 'passwd': passWord "submit": sumbit,}
- #Post request to login url, with form data and header/s (Could this be where the issue lies?)
- c.post(url, data = login_data, headers = {'Referer': 'http://itsupport.work.com.au/scp/login.php', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36'})
- #Testing if I've logged into the site, however I only get back the contents of the login page; meaning I didn't successfully login
- page = c.get('http://itsupport.work.com.au/scp/dashboard.php')
- print(page.content)
- time.sleep(40)
Add Comment
Please, Sign In to add comment