0

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 ?

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
dragon
  • 81
  • 1
  • 8

1 Answers1

0

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)
Brian
  • 1,659
  • 12
  • 17
  • it works thanks :) ,. But can you tell me what's the problem in my code or in my way ? – dragon Aug 02 '16 at 21:01
  • Your method is trying to hijack a session, and most servers have code to prevent people from doing that. This is because you could potentially do this in a very malicious way. – Brian Aug 03 '16 at 23:52