Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dzmitry-duboyski/solving-yandex-smart-captcha-using-puppeteer
Решение капчи Yandex SmartCaptcha от Яндекса с использованием библиотеки Puppeteer и сервиса 2captcha. Демо автоматизации обхода капчи Yandex Smart Captcha.
https://github.com/dzmitry-duboyski/solving-yandex-smart-captcha-using-puppeteer
2captcha 2captcha-api bypass-captcha bypass-captcha-jandex bypass-captcha-puppeteer bypass-yandex captcha-solving javascript nodejs puppeteer puppeteer-demo yandex yandex-captcha yandex-smart-captcha
Last synced: 1 day ago
JSON representation
Решение капчи Yandex SmartCaptcha от Яндекса с использованием библиотеки Puppeteer и сервиса 2captcha. Демо автоматизации обхода капчи Yandex Smart Captcha.
- Host: GitHub
- URL: https://github.com/dzmitry-duboyski/solving-yandex-smart-captcha-using-puppeteer
- Owner: dzmitry-duboyski
- License: mit
- Created: 2023-05-01T07:50:37.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-10T09:52:02.000Z (4 days ago)
- Last Synced: 2024-11-10T10:31:26.288Z (4 days ago)
- Topics: 2captcha, 2captcha-api, bypass-captcha, bypass-captcha-jandex, bypass-captcha-puppeteer, bypass-yandex, captcha-solving, javascript, nodejs, puppeteer, puppeteer-demo, yandex, yandex-captcha, yandex-smart-captcha
- Language: JavaScript
- Homepage:
- Size: 22.5 KB
- Stars: 21
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.en.md
- License: LICENSE
Awesome Lists containing this project
README
# Automating Yandex SmartCaptcha solution using Puppeteer library
## Description
This example shows how to automate the solution of Yandex SmartCaptcha on the demo captcha page https://captcha-api.yandex.ru/demo. For automation we use the library [Puppeteer](https://pptr.dev/) and the captcha solving service [2captcha.com]. For correct work of the example you need `APIKEY`, for this you need to have an account in the service [2captcha.com], `APIKEY` is displayed in your personal cabinet.
## Usage
### Clone
`git clone https://github.com/dzmitry-duboyski/solving-yandex-smart-captcha-using-puppeteer.git`
### install dependens
`npm install`### configure
Set up you `APIKEY` in [./index.js#L3](./index.js#L3)
> `APIKEY` is specified in your [2captcha.com] account. Before copying `APIKEY`, make sure that the **"developer"** role is selected in your account.
### Start
`npm run start`
## Source code
```js
import puppeteer from "puppeteer";
import { Solver } from "2captcha-ts";
const solver = new Solver("");;(async () => {
const browser = await puppeteer.launch({
headless: false,
});const page = await browser.newPage();
// Open target page
await page.goto("https://captcha-api.yandex.ru/demo");
await page.waitForSelector("#captcha-container");
await page.waitForSelector("iframe[data-testid='checkbox-iframe'");// Enter data
await page.$eval("#name", (el) => (el.value = ""));
await page.type("#name", "John Doe", { delay: 100 });// Get the `sitekey` parameter from the current page
const sitekey = await page.evaluate(() => {
return document
.querySelector("#captcha-container")
.getAttribute("data-sitekey");
});// Send a captcha to the 2captcha service to get a solution
const res = await solver.yandexSmart({
pageurl: "https://captcha-api.yandex.ru/demo",
sitekey: sitekey,
});console.log(res);
// The resulting solution
const captchaAnswer = res.data;// Use the resulting solution on the page
const setAnswer = await page.evaluate((captchaAnswer) => {
document.querySelector("input[data-testid='smart-token']").value =
captchaAnswer;
}, captchaAnswer);// Click on the 'Submit' button to check the captcha solution
await page.click("#smartcaptcha-demo-submit");await page.waitForSelector(".greeting");
console.log("Captcha solved successfully!!!");
browser.close();
})();
```Source code [index.js](/index.js)
> [!IMPORTANT]
> If you need to solve the Yandex captcha that needs to be clicked, it is recommended to use [Coordinates API v1](https://2captcha.com/api-rucaptcha#coordinates?from=16653706) \ [Coordinates API v2](https://2captcha.com/api-docs/coordinates?from=16653706) method, more details are described in [article](https://captchaforum.com/threads/reshenie-kapchi-na-servisax-jandeks.4351/).## Usefull links:
- [Documentation on sending Yandex SmartCaptcha to 2captcha.com service (web.archive)](https://web.archive.org/web/20230917233148/https://rucaptcha.com/api-rucaptcha#yandex)
- [How to Bypass Yandex SmartCaptcha (web.archive)](https://web.archive.org/web/20230320212755/https://rucaptcha.com/p/yandex-captcha-bypass-service)
- [Article - Solving captcha on Yandex services with clicks](https://captchaforum.com/threads/reshenie-kapchi-na-servisax-jandeks.4351/)
- [Method Coordinates](https://2captcha.com/api-docs/coordinates/?from=16653706)
[2captcha.com]: https://2captcha.com/?from=16653706