Answer the question
In order to leave comments, you need to log in
Python requests how to get authorized on the site?
Hello dear experts
There is a problem I can't log in on the site https://alfapolicy.alfastrah.ru/AlfaPolicy/#!
The form itself is loaded via JS
It is not clear how to correctly pass the login password to the request and where
my code
URL = 'https://alfapolicy.alfastrah.ru/AlfaPolicy/UIDL/?v-uiId=4'
LOGIN = 'login'
PASS = 'pass'
header = {'user_agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/83.0.4103.61 Chrome/83.0.4103.61 Safari/537.36'}
payload = {"csrfToken":"3eadbf2f-d2a8-4804-bc8e-bf06c27e42ab","rpc":],"syncId":3,"clientId":3}
sess = requests.Session()
r = sess.post(URL, headers=header, json=payload)
print(r.headers)
print(r.request.url)
print(r)
print(r.text)
{'Server': 'nginx/1.11.3', 'Date': 'Thu, 11 Jun 2020 11:12:27 GMT', 'Content-Type': 'application/json;charset=UTF-8', 'Content-Length': '291', 'Connection': 'keep-alive'}
https://alfapolicy.alfastrah.ru/AlfaPolicy/UIDL/?v-uiId=4
<Response [200]>
for(;;);[{"changes":{},"resources":{},"locales":{},"meta":{"appError":{"caption":"Cookies disabled","url":null,"message":"This application requires cookies to function.<br/>Please enable cookies in your browser and <u>click here</u> or press ESC to try again.","details":null}},"syncId":-1}]
Answer the question
In order to leave comments, you need to log in
Before the POST request, you need to collect cookies on the site.
sess.get('https://alfapolicy.alfastrah.ru/AlfaPolicy/#!singin')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question