-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
2captcha
committed
Sep 28, 2022
0 parents
commit fcac868
Showing
6 changed files
with
1,608 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules | ||
2captcha-solver*.zip | ||
2captcha-solver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
[English](README.md) | [Русский](README.ru.md) | ||
# usage-2captcha-solver-in-puppeteer | ||
|
||
## Description | ||
|
||
This demo project shows how to use the [2captcha-solver](https://chrome.google.com/webstore/detail/2captcha-solver-auto-reco/ifibfemgeogfhoebkmokieepdoobkbpo) plugin with [Puppeteer](https://pptr.dev/) to solve captchas at https://2captcha.com/demo/recaptcha-v2. | ||
The example uses [Puppeteer](https://pptr.dev/), [puppeteer-extra](https://www.npmjs.com/package/puppeteer-extra) and [puppeteer-extra-plugin-stealth](https://www.npmjs.com/package/puppeteer-extra-plugin-stealth). [puppeteer-extra](https://www.npmjs.com/package/puppeteer-extra) is a lightweight wrapper around Puppeteer and [puppeteer-extra-plugin-stealth](https://www.npmjs.com/package/puppeteer-extra-plugin-stealth) is an add-on to [puppeteer-extra](https://www.npmjs.com/package/puppeteer-extra) designed to hide the traces of automation. | ||
|
||
A detailed description of how this example works is described in our article [How to use the 2captcha-solver plugin in Puppeteer](https://2captcha.com/blog/how-to-use-2captcha-solver-plugin-in-puppeteer). | ||
|
||
## Download the extension | ||
|
||
Download the [latest extension release](https://github.com/2captcha/2captcha-solver/releases/latest) and extract it to `2captcha-solver` folder | ||
|
||
## Install the dependencies | ||
|
||
`npm i` | ||
|
||
## Setting | ||
Write your api key in the file `'./2captcha-solver/common/config.js '`. You can view your API key on the page https://2captcha.com/setting. | ||
|
||
Example: | ||
|
||
`apiKey: "7894561d1234ddd00b7894561dd0d00d"` | ||
|
||
## Usage | ||
|
||
`npm run start` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
[English](README.md) | [Русский](README.ru.md) | ||
# usage-2captcha-solver-in-puppeteer | ||
|
||
## Описание | ||
|
||
В этом демонстрационном проекте показано, как использовать плагин [2captcha-solver](https://chrome.google.com/webstore/detail/2captcha-solver-auto-reco/ifibfemgeogfhoebkmokieepdoobkbpo) вместе с [Puppeteer](https://pptr.dev/), для решения капчи на странице https://2captcha.com/demo/recaptcha-v2. | ||
|
||
В примере используется [Puppeteer](https://pptr.dev/), [puppeteer-extra](https://www.npmjs.com/package/puppeteer-extra) и [puppeteer-extra-plugin-stealth](https://www.npmjs.com/package/puppeteer-extra-plugin-stealth). [puppeteer-extra](https://www.npmjs.com/package/puppeteer-extra) это легкая оболочка вокруг [Puppeteer](https://pptr.dev/), а [puppeteer-extra-plugin-stealth](https://www.npmjs.com/package/puppeteer-extra-plugin-stealth) это дополнение к [puppeteer-extra](https://www.npmjs.com/package/puppeteer-extra), предназначенное для скрытия следов автоматизации. | ||
|
||
Подробное описание работы этого примера, описано в нашей статье [Использование плагина 2captcha-solver в Puppeteer](https://2captcha.com/blog/ispolzovanie-plagina-2captcha-solver-v-puppeteer). | ||
|
||
## Загрузка расширения | ||
|
||
Скачайте [последний релиз расширения](https://github.com/2captcha/2captcha-solver/releases/latest) и распакуйте его в папку `2captcha-solver` | ||
|
||
## Установка зависимостей | ||
|
||
`npm i` | ||
|
||
## Настройка | ||
Укажите свой `apiKey` в файле `'./2captcha-solver/common/config.js'`. Свой API key вы можете посмотреть на странице https://2captcha.com/setting. | ||
|
||
Пример: | ||
|
||
`apiKey: "7894561d1234ddd00b7894561dd0d00d"` | ||
|
||
## Запуск | ||
|
||
`npm run start` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// puppeteer-extra is a drop-in replacement for puppeteer, | ||
// it augments the installed puppeteer with plugin functionality | ||
const puppeteer = require('puppeteer-extra'); | ||
|
||
// add stealth plugin and use defaults (all evasion techniques) | ||
const StealthPlugin = require('puppeteer-extra-plugin-stealth'); | ||
|
||
(async () => { | ||
const pathToExtension = require('path').join(__dirname, '2captcha-solver'); | ||
puppeteer.use(StealthPlugin()) | ||
const browser = await puppeteer.launch({ | ||
headless: false, | ||
// headless: false, | ||
args: [ | ||
`--disable-extensions-except=${pathToExtension}`, | ||
`--load-extension=${pathToExtension}`, | ||
], | ||
}); | ||
|
||
const [page] = await browser.pages() | ||
|
||
// переходим по указанному адресу | ||
await page.goto('https://2captcha.com/demo/recaptcha-v2') | ||
|
||
// ждем пока появится элемент с CSS селектором ".captcha-solver" | ||
await page.waitForSelector('.captcha-solver') | ||
// кликаем по элементу с указанным селектором | ||
await page.click('.captcha-solver') | ||
|
||
// По умолчанию waitForSelector ожидает в течении 30 секунд, так как этого времени зачастую не достаточно, то указываем значение timeout вручную вторым параметром. | ||
// Значение timeout указывается в "ms". | ||
await page.waitForSelector(`.captcha-solver[data-state="solved"]`, {timeout: 150000}) | ||
|
||
// После решения капчи выполняем необходимые действия, в нашем случае нажимаем на кнопку "check". | ||
await page.click("button[type='submit']") | ||
|
||
// await browser.close(); | ||
|
||
})(); |
Oops, something went wrong.