From a882f6befef7d402081dd40380e7dd258f663658 Mon Sep 17 00:00:00 2001 From: Josh Date: Sat, 9 Feb 2019 17:41:21 -0500 Subject: [PATCH] changed referer --- penn/wharton.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/penn/wharton.py b/penn/wharton.py index 6d009d4..d1bd91f 100644 --- a/penn/wharton.py +++ b/penn/wharton.py @@ -63,15 +63,22 @@ def delete_booking(self, sessionid, booking_id): raise APIError("Wharton Auth Failed. Session ID is not valid.") soup = BeautifulSoup(html, "html5lib") - csrftoken = resp.cookies['csrftoken'] middleware_token = soup.find("input", {'name': "csrfmiddlewaretoken"}).get('value') + + csrftoken = resp.cookies['csrftoken'] cookies2 = {'sessionid': sessionid, 'csrftoken': csrftoken} + reservationsUrl = "{}{}".format(BASE_URL, "/reservations") + headers = {'Referer': reservationsUrl} + payload = {'csrfmiddlewaretoken': middleware_token} - headers = {'Referer': url} + print(csrftoken) + print(middleware_token) + print(headers) + print(payload) try: - resp2 = requests.post(url, cookies=cookies2, data={'csrfmiddlewaretoken': middleware_token}, headers = headers) + resp2 = requests.post(url, cookies=cookies2, data=payload, headers = headers) except resp.exceptions.HTTPError as error: raise APIError("Server Error: {}".format(error))