mercredi 28 novembre 2018

Python login script returning with status code 419

I have the following python script running to login to a website, the script executes but returns a 419 and doesn't let me login. I think its something to do with the _token parameter or cookies. Is there a way I can get this _token key or generate it programatically.

import requests
import json

url = "https://labhotel.net/"
headers = {
"accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
"accept-encoding" : "gzip, deflate, br",
"Accept-Language" : "en-US,en;q=0.9",
"cache-control":"max-age=0",
"Content-Type" : "application/x-www-form-urlencoded",
"Origin": "https://labhotel.net",
"User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.52 Safari/536.5",
"Referer": "https://labhotel.net/",
}
data = {"_token" :"","username" :"", "password":""}
response = requests.post(url, data=data, headers=headers)

print(response.status_code)
print(response.text)




Aucun commentaire:

Enregistrer un commentaire