dragon dragon - 1 year ago 67
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


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 Source

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)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download