Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pguardiario/captchas
Solve captchas for Puppeteer / Selenium
https://github.com/pguardiario/captchas
captcha captcha-breaking captcha-recaptcha captcha-solver captcha-solving hcaptcha puppeteer selenium
Last synced: about 2 months ago
JSON representation
Solve captchas for Puppeteer / Selenium
- Host: GitHub
- URL: https://github.com/pguardiario/captchas
- Owner: pguardiario
- Created: 2020-05-30T03:02:15.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-06-13T04:23:01.000Z (over 1 year ago)
- Last Synced: 2023-10-20T22:19:59.446Z (about 1 year ago)
- Topics: captcha, captcha-breaking, captcha-recaptcha, captcha-solver, captcha-solving, hcaptcha, puppeteer, selenium
- Language: JavaScript
- Homepage: https://captchas.vercel.app
- Size: 28.3 KB
- Stars: 19
- Watchers: 1
- Forks: 10
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# captchas
Solve hCaptcha / reCaptcha v2 for Puppeteer / Selenium (2captcha.com account required)### Selenium
```python
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import timedriver = webdriver.Chrome()
driver.get('https://www.site-with-captcha.com/')from requests import get
body = get("https://raw.githubusercontent.com/pguardiario/captchas/master/captchas.js").content.decode('utf8')
driver.set_script_timeout(120)
api_key = 'Your 2captcha API key'
status = driver.execute_async_script(body, api_key, {})
print(status)
time.sleep(1)
```
### Puppeteer
```javascript
const puppeteer = require('puppeteer'); (async () => {
const browser = await puppeteer.launch()
const page = await browser.newPage()
await page.goto('https://www.site-with-captcha.com/')
await page.addScriptTag({url: "https://cdn.jsdelivr.net/gh/pguardiario/captchas/captchas.js"})
let status = await page.evaluate(async () => {
return new Promise((resolve, reject) => {
solve([your_api_key, {}, resolve])
})
})switch(status){
case 'NO_CAPTCHAS':
case 'OK':
break
case 'ERROR_ZERO_BALANCE':
console.log('no captcha balance!!!!!')
case 'ERROR_CAPTCHA_UNSOLVABLE':
console.log('retrying')
// try again ?
default:
debugger
}// evaluate returns before the submit / captcha callback so wait 1 second.
await page.waitFor(1000)
})()
```