Reputation: 263
Heyo,
Able to log into my school website using requests and the .post method (Trying to create a feed showing when new results are up)
url = "https://pipeline.tsc.nsw.edu.au/scots/pages/main/login.php"
payload = {'username': 'my.name', 'password': 'password'}
with requests.Session() as s:
r = s.post(url, data=payload)
print(r.text) # Write to file and create filter to check against old code
The difficulty I'm having is that the website seems to generate a url for you with an 'eduId' in the browser bar e.g
https://pipeline.tsc.nsw.edu.au/scots/pages/mainframe.php?eduId=3993834&displayID=&theme=scots&version=4.2.2&demo=-1
You're redirected to this url when you successfully login to the site but I can't seem to get it with requests.
Does anybody know how to handle the redirect or gather the redirected URL? Thanks
NOTE: For all I can tell the login is either not taking place or not registering the redirect as the incorrect login message doesn't show up in the downloaded code
Upvotes: 1
Views: 95
Reputation: 528
I suggest that you take a look at the Mechanize python lib, Mechanize behaves like a browser and make it simpler to handle sessions, redirects etc. http://wwwsearch.sourceforge.net/mechanize/
Upvotes: 1