Python login script to CSRF protected web site -


i trying create simple login script rol.redhat.com web site. here example:

import sys import requests  url = 'https://rol.redhat.com/rol/rhz/login'  # csrf token client = requests.session() client.get(url) token = client.cookies['csrftoken']  # login login_data = dict(username='username', password='password',csrftoken=token) r = client.post(url, data=login_data, headers=dict(referer=url)) print r.status_code print r.text 

but receiving this:

403

(...)

forbidden (403)

csrf verification failed. request aborted.

(...)

what wrong in script?


Comments

Popular posts from this blog

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -