Home>

Good hour
Not familiar with using post requests in python to solve this kind of problem. Below I will write down the details, please explain what data you need to transfer in the post request, please also write the code for this request
The essence is as follows: when changing the password from the account in the rambler mail, you need to enter a captcha. I solved the captcha through the service, receiving a solution token in response, but I can’t imagine how to send it. Everything works on python + selenium + requests
The block with captcha is in the following form:

<iframe src="https://newassets.hcaptcha.com/captcha/v1/9f58d19/static/hcaptcha-checkbox.html#id=1sruemy18uwp&
amp;host=id.rambler.ru&
amp;sentry=true&
amp;reportapi=https%3A%2F%2Faccounts.hcaptcha.com&
amp;recaptchacompat=off&
amp;custom=false&
amp;hl=en&
amp;tplinks=on&
amp;sitekey=322e5e22-3542-4638-b621-fa06db098460&
amp;theme=light" title="widget containing checkbox for hCaptcha security challenge" tabindex="0" frameborder="0" scrolling="no" data-hcaptcha-widget-id="1sruemy18uwp" data-hcaptcha-response="style="width: 303px; height: 78px; overflow: hidden;">    #document
</iframe><textarea id="h-captcha-response-1sruemy18uwp" name="h-captcha-response" style="display: none;"></textarea>

When solving captcha by tracking events in developer tools (I use google chrome), 1 post request occurs:

Headers=> General
Request URL: https://hcaptcha.com/checkcaptcha/E0_eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJkYXRhIjoiUFBvbU0vUXJjVVpOenlHOENvSVlpOEVCK2RwSElDU1IrVlk5V1QxNXRTU3RwRWtkcGVmZ2MvVlB6R1phUmlINmtMMkU1SSs3MTZwOTFyUXB2aTlsa29FV0R2MHg1bGNuMyttVVZQL3FBay82RnptU29IK255OXdRVXlsN292aittdkZCRVJISWREdVhpaTdXWEtYRDhIVFBtRGxYUmRJL2lYaWtrMU16QzRZY1Rub2FMOFJPRjJnTmdzaW50T29tZm5xT3NGcjdFbTNyRUR1ZktDV0FWb05IVk5KNHFxeWw2R1M2RlBGQ2hTYVgxTDJ6SGlSR0pXaXhYRE8zay9IMC9BeG1HQTY5S2wzWUNEN0drdz09MVNFV2dFVStheXQ5YXVvWiJ9.G6z8gXvWYoUV_KZAnP8SqWwHMac0B7lnL1R8q9P28Tg?s=322e5e22-3542-4638-b621-fa06db098460
Request Method: POST
Status Code: 200

The link contains the following form: solved captcha}?s={site key}\

Request headers
:authority:hcaptcha.com
:method: POST
: Path: /checkcaptcha/E0_eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJkYXRhIjoiUFBvbU0vUXJjVVpOenlHOENvSVlpOEVCK2RwSElDU1IrVlk5V1QxNXRTU3RwRWtkcGVmZ2MvVlB6R1phUmlINmtMMkU1SSs3MTZwOTFyUXB2aTlsa29FV0R2MHg1bGNuMyttVVZQL3FBay82RnptU29IK255OXdRVXlsN292aittdkZCRVJISWREdVhpaTdXWEtYRDhIVFBtRGxYUmRJL2lYaWtrMU16QzRZY1Rub2FMOFJPRjJnTmdzaW50T29tZm5xT3NGcjdFbTNyRUR1ZktDV0FWb05IVk5KNHFxeWw2R1M2RlBGQ2hTYVgxTDJ6SGlSR0pXaXhYRE8zay9IMC9BeG1HQTY5S2wzWUNEN0drdz09MVNFV2dFVStheXQ5YXVvWiJ9.G6z8gXvWYoUV_KZAnP8SqWwHMac0B7lnL1R8q9P28Tg?s=322e5e22-3542-4638-b621-fa06db098460
:scheme:https
accept: */*
accept-encoding: gzip, deflate, br
accept-language: ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7
content-length: 14908
content-type: application/json;charset=UTF-8
origin: https://newassets.hcaptcha.com
referrer: https://newassets.hcaptcha.com/
sec-ch-ua: "Not;A Brand";v="99", "Google Chrome";v="97", "Chromium";v="97"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "Windows"
sec-fetch-dest: empty
sec-fetch-mode: cors
sec-fetch-site: same-site
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36

I tried to make the following request but nothing changed in selenium:

post= f'https://hcaptcha.com/checkcaptcha/{g_response}?s={site_key}'
requests.post(post)

I tried to describe the problem in as much detail as possible, tell me if you need to correct /write something in more detail. I understand that for the post request, other data are also necessary, but I just can’t imagine what and where to take them from. I would be grateful if you write the code to solve the problem