dragon dragon - 4 months ago 12
Python Question

Enter page that you have to be logged in

I need To send get request To page that I have to login first

using

requests module


I tried to first send post request and make login with my information

Then using cookies which is [phpsessionid] & send it with the get request

cookie = {'PHPSESSID': 'm7v485i9g1rfm3tqcn0aa531rvjf5d26'}

x = requests.get('https://www.example.com/',cookies=cookie)


but it doesn't work !

And idea on how to open the page ?

Answer

Instead of trying to hijack a session, login using requests with something like:

session = requests.session()
session.post(loginUrl, data={'username':username, 'password':password, ... (anything else the login page posts)}
response = session.get(anyInternalPage)
Comments