2
Well I’m trying to create a script who enters a website without having to log in through the library requests
. I want to do it using the PHPSESSID
.
How can I do this?
2
Well I’m trying to create a script who enters a website without having to log in through the library requests
. I want to do it using the PHPSESSID
.
How can I do this?
1
To send cookies together with request, using the lib requests:
import requests
s = requests.Session()
r = s.get('http://httpbin.org/cookies', cookies={'CHAVE1': 'VALOR1', 'CHAVE2': 'VALOR2'})
print(r.status_code)
print(r.text)
Remember that there is probably not only one verification cookie, you have to send them all. This example in principle works both in python2 and 3.
Can set headers also and send 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'})
OK thank you! I’ll test
Thank you very much I managed sending only the PHPSESSID thank you very much I was researching there are two days.
ready friend clicked !
Browser other questions tagged python python-3.x python-2.7
You are not signed in. Login or sign up in order to post.
Why without the requests library?
– Miguel
in vdd I need it, the problem is I don’t want to send login/password. I just want to send PHPSESSID instead of having to log in understand? It is q the site I want to enter has captcha there is no way to send the Formularios, then the way would be log in through the browser, pick up the cookies and do a kind q a 'hijack'.
– Leonardo Julio
I understand, but how do you want to grab a valid PHPSESSID without logging in first? This will need to be checked on the server side and the server will see if PHPSESSID equals what it has saved for that session. And this is only set when logging in... No PHPSESSID login in this context does not exist. You can do all this with requests... If I may say, what is the site? see if I can help you
– Miguel
of course, but I will login through the browser, then I get the browser ID and play in my script.
– Leonardo Julio
Ha ok... I see. You will have to send all cookies... Most likely you will not only have this saved
– Miguel
the website and br.hackerexperience.com
– Leonardo Julio
br.hackerexperience.com
– Leonardo Julio
You know the code needed to send a cookie through requests?
– Leonardo Julio
I put down the way to do this, along with the documentation link
– Miguel