Skip to content

Commit

Permalink
changed referer
Browse files Browse the repository at this point in the history
  • Loading branch information
joshdoman committed Feb 9, 2019
1 parent cfdefc3 commit a882f6b
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions penn/wharton.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down

0 comments on commit a882f6b

Please sign in to comment.