Python Module
Uses Python to automatically solve captchas.
Supports image clicking, slider dragging, and other captcha types.
Latest Version
| Version | Changes | Download |
|---|---|---|
| 0.2 | Fix hcap | Download |
| 0.1 | Initial release | Download |
Copy the captcha_solver folder into your project.
Usage
Import CaptchaSolver from the package.
Copy the code from the example for the type you need.
Pass the page containing the captcha and your API key.
Call the appropriate captcha solving method.
Allow a few seconds for the captcha interaction to complete.
Examples
py
# pip install playwright playwright-stealth
# playwright install chrome
import asyncio
from playwright.async_api import async_playwright
from playwright_stealth import stealth_async
from captcha_solver import CaptchaSolver
async def main():
async with async_playwright() as p:
browser = await p.chromium.launch(
headless=False,
channel="chrome",
args=["--disable-blink-features=AutomationControlled"],
)
page = await browser.new_page()
await stealth_async(page)
await page.goto('https://site.com/cap')
solver = CaptchaSolver(
page=page,
api_key='YOUR_KEY',
debug=True,
attempts=5,
)
await solver.solve_other()
await browser.close()
asyncio.run(main())py
# pip install playwright
# playwright install
import asyncio
from playwright.async_api import async_playwright
from captcha_solver import CaptchaSolver
async def main():
async with async_playwright() as p:
browser = await p.chromium.launch(headless=False)
page = await browser.new_page()
await page.goto('https://site.com/cap')
solver = CaptchaSolver(
page=page,
api_key='YOUR_KEY',
debug=True,
attempts=5,
)
await solver.solve_other()
await browser.close()
asyncio.run(main())py
# pip install selenium
# Firefox browser and geckodriver must be installed
from selenium import webdriver
from captcha_solver import CaptchaSolver
def main():
options = webdriver.FirefoxOptions()
# options.add_argument('--headless')
driver = webdriver.Firefox(options=options)
try:
driver.get('https://site.com/cap')
solver = CaptchaSolver(
driver=driver,
api_key='YOUR_KEY',
debug=True,
attempts=5,
)
solver.solve_other()
finally:
driver.quit()
if __name__ == '__main__':
main()py
# pip install undetected-chromedriver
# Chrome browser must be installed
import undetected_chromedriver as uc
from captcha_solver import CaptchaSolver
def main():
driver = uc.Chrome(headless=False)
try:
driver.get('https://site.com/cap')
solver = CaptchaSolver(
driver=driver,
api_key='YOUR_KEY',
debug=True,
attempts=5,
)
solver.solve_other()
finally:
driver.quit()
if __name__ == '__main__':
main()py
# pip install selenium
# Chrome browser and chromedriver must be installed
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from captcha_solver import CaptchaSolver
def main():
options = webdriver.ChromeOptions()
# options.add_argument('--headless')
service = Service() # укажите путь: Service('/path/to/chromedriver')
driver = webdriver.Chrome(service=service, options=options)
try:
driver.get('https://site.com/cap')
solver = CaptchaSolver(
driver=driver,
api_key='YOUR_KEY',
debug=True,
attempts=5,
)
solver.solve_other()
finally:
driver.quit()
if __name__ == '__main__':
main()py
# pip install selenium-wire undetected-chromedriver
# Chrome browser must be installed
import seleniumwire.undetected_chromedriver as uc
from captcha_solver import CaptchaSolver
def main():
options = uc.ChromeOptions()
# options.add_argument('--headless')
driver = uc.Chrome(options=options, headless=False)
try:
driver.get('https://site.com/cap')
solver = CaptchaSolver(
driver=driver,
api_key='YOUR_KEY',
debug=True,
attempts=5,
)
solver.solve_other()
finally:
driver.quit()
if __name__ == '__main__':
main()Call the appropriate method:
await solver.solve_recaptcha2()
await solver.solve_hcaptcha()
await solver.solve_other()
await solver.solve_geetest()
await solver.solve_funcaptcha()
await solver.solve_tiktok()Supported Captchas
| reCaptcha2 | FunCaptcha | TikTok | GeeTest | hCaptcha | Other |
|---|---|---|---|---|---|
| Yes | Yes | Yes | Yes | Yes | Yes |
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
page | Page | — | Page containing the captcha |
api_key | str | — | Cap.Guru API key |
attempts | int | 5 | Max number of attempts |
debug | bool | False | Enable debug logging |
selector | str | '' | CSS selector of the captcha container |
Error Handling
All solvers raise RuntimeError on failure:
python
try:
await solver.solve_recaptcha2()
except RuntimeError as e:
if 'ERROR_CAPTCHA_UNSOLVABLE' in str(e):
print('Captcha was not solved after all attempts')