I am trying to login to a website using python requests library, but keep getting a 401 status code.
I have tried many variations of the various post function variables including:
data = formData
, form data includes the correctusername
,password
and_csrf
tokendata = json.dumps(formData)
headers = headers
(which included the "user-agent" and many other fields)auth = HTTPBasicAuth(username,password)
whereusername
andpassword
are the correct string variables for the site login
with requests.Session() as c:
loginPage = c.get(LoginURL)
loggedInPage = c.post(LoginURL,
data=formData,
headers=headers,
auth=HTTPBasicAuth(username,password)
)