P
P
Pavel2020-06-11 14:27:40
Python
Pavel, 2020-06-11 14:27:40

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)


the output is the following
{'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}]


Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2020-06-11
@SoreMix

Before the POST request, you need to collect cookies on the site.

sess.get('https://alfapolicy.alfastrah.ru/AlfaPolicy/#!singin')

ps: csrftoken is updated, it needs to be parsed before the request. The remaining parameters are also some kind of local captcha, it is unlikely that you will be able to enter, you need to look at how the parameters are compiled

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question