I'm getting error while i'm trying to fetch the csrftoken.
I tried changing the token name from csrftoken to csrf but i'm still getting the error.
import requests
url='myurl'
Username='username'
Password='password'
requests.Session().get(url)
csrftoken= requests.Session().cookies['csrftoken']
logindata=dict(csrfmiddlewaretoken=csrftoken,username=
Username,password=Password)
requests.Session().post(url,data=logindata,headers={'referer' :'homepage'})
page=requests.session().get('2nd url')
print page.content
The error is :-
File "C:\Users\dell\AppData\Local\Programs\Python\Python36-32\lib\site-packa es\requests\cookies.py", line 329, in __getitem__return self._find_no_duplicates(name)'
File "C:\Users\dell\AppData\Local\Programs\Python\Python36-32\lib\site-packa es\requests\cookies.py", line 400, in _find_no_duplicates raise KeyError('name=%r, domain=%r, path=%r' % (name, domain, path)) eyError: "name='csrftoken', domain=None, path=None"'