V
V
Vladislav2021-05-05 10:52:37
PHP
Vladislav, 2021-05-05 10:52:37

How to pass hCaptcha captcha using RuCaptcha?

The stack that I use: php, yii, selenium
I'm trying to access https://spotifycharts.com/

My actions, I get frame captcha:
#cf-hcaptcha-container > iframe
and get src from there. Next, I extract the sitekey:

private static function extractHCaptchaCode($url)
    {
        preg_match('~sitekey=(?<sitekey>.+?)(&|$)~ui', $url, $result);
        return !empty($result['sitekey']) ? $result['sitekey'] : false;
    }


And send the handcaptcha to the server:
public static function solveHCaptcha($code, $url_with_captcha)
    {
        $params = [
            'key' => Yii::$app->params['rucaptcha_api_key'],
            'method' => 'hcaptcha',
            'sitekey' => $code,
            'pageurl' => $url_with_captcha,
            'json' => 1,
        ];
        $url = 'http://rucaptcha.com/in.php?' . http_build_query($params);
        $client = new Client();
        $response = $client->createRequest()
            ->setMethod('GET')
            ->setUrl($url)
            ->send();
        if ($response->isOk && $response->data['status'] != 0)
        {
            $response_id = $response->data['request'];
            return self::waitResult($response_id);
        }
    }


Well, we are waiting for the actual solution, as soon as the answer comes, we send the result:
$this->selenium->executeScript("
                document.querySelector('[name=h-captcha-response]').innerText = '$result_rucaptcha';
                document.querySelector('#challenge-form').submit();


The problem is that when I wrote this everything worked, the captcha was passed. The next day it just stopped working.
I immediately thought that they define the webdriver
and made it so that everything green in selenium was here: https://infosimples.github.io/detect-headless/
but it didn’t help, it still doesn’t pass the captcha, the page just refreshes and everything is new ... so ad infinitum, it does not accept the result and that's it.

Maybe someone came across knows how to get through it?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question