Answer the question
In order to leave comments, you need to log in
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;
}
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);
}
}
$this->selenium->executeScript("
document.querySelector('[name=h-captcha-response]').innerText = '$result_rucaptcha';
document.querySelector('#challenge-form').submit();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question