Skip to content

Instantly share code, notes, and snippets.

@peketamin
Last active July 25, 2019 09:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peketamin/7e20e15d26cbac0fa5db394b0b1ddabd to your computer and use it in GitHub Desktop.
Save peketamin/7e20e15d26cbac0fa5db394b0b1ddabd to your computer and use it in GitHub Desktop.
requests_post_with_csrf.py
import requests
url = 'http://localhost:8000/xxx/unsubscribe/xxx'
session = requests.session()
res_get = session.get(url)
resp_post = session.post(
url,
data={"csrfmiddlewaretoken" : session.cookies['csrftoken']},
headers={'referer': url}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment