Python requests returns: CSRF verification failed. Request aborted -


i want login account follow:

>> session=requests.session() >> session.get('http://mywebsite.com') >> csrftoken=session.cookies['thisismytoken'] 

but following error occurs:

traceback (most recent call last):   file "<stdin>", line 1, in <module>   file "/usr/lib/python2.7/dist-packages/requests/cookies.py", line 276, in __getitem__     return self._find_no_duplicates(name)   file "/usr/lib/python2.7/dist-packages/requests/cookies.py", line 331, in _find_no_duplicates     raise keyerror('name=%r, domain=%r, path=%r' % (name, domain, path)) keyerror: "name='thisismytoken', domain=none, path=none" 

you trying access cookie request, should access response, this:

resp = session.get('http://mywebsite.com') csrftoken = resp.cookies['thisismytoken'] 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -