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

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -