I'm trying to create a script that enters a website without having to log in through the requests
library. I want to do this using the PHPSESSID
cookie.
How can I do this?
I'm trying to create a script that enters a website without having to log in through the requests
library. I want to do this using the PHPSESSID
cookie.
How can I do this?
To send cookies together with request , using the lib :
import requests
s = requests.Session()
r = s.get('http://httpbin.org/cookies', cookies={'CHAVE1': 'VALOR1', 'CHAVE2': 'VALOR2'})
print(r.status_code)
print(r.text)
Please note that there is probably not only one verification cookie, you will need to submit all cookies. This example works in both python2 and 3.
You can also set the headers and send them together:
...
headers = {'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:47.0) Gecko/20100101 Firefox/47.0'}
r = s.get('http://httpbin.org/cookies', headers=headers, cookies={'CHAVE1': 'VALOR1', 'CHAVE2': 'VALOR2'})