hCaptcha
Beta Feature
hCaptcha solving is currently in beta and works best with checkbox variations. Enterprise hCaptcha solving support will be added soon.
Overview
Surfskyprovides automated hCaptcha solving capabilities through the CDP API. This feature uses AI-powered visual recognition to solve hCaptcha challenges automatically.
Prerequisites
Gemini API Key
To use the hCaptcha solver, you'll need a Google Gemini API key:
- Visit Google AI Studio
- Sign in with your Google account
- Click "Create API Key"
- Copy your API key for use in the solver
caution
Keep your API key secure and never commit it to version control. Use environment variables or secure configuration management.
Basic Usage
The hCaptcha solver is accessed through the CDP API using the Captcha.solve
method. Here's how to implement it:
- Python
- JavaScript
import asyncio
from playwright.async_api import async_playwright
async def solve_hcaptcha_example():
async with async_playwright() as p:
# ...
page = browser.contexts[0].pages[0]
# Create CDP session
client = await page.context.new_cdp_session(page)
# Navigate to page with hCaptcha
await page.goto("https://example.com/hcaptcha-page", wait_until="load")
# Set up event listeners
def on_solve_finished(params):
print(f"hCaptcha solved successfully: {params}")
def on_solve_failed(params):
print(f"hCaptcha solving failed: {params}")
client.on("Captcha.solveFinished", on_solve_finished)
client.on("Captcha.solveFailed", on_solve_failed)
# Trigger hCaptcha solving
print("Sending Captcha.solve command...")
await client.send("Captcha.solve", {
"type": "hcaptcha",
"options": {
"gemini_api_key": "YOUR_GEMINI_API_KEY_HERE"
}
})
# ...
await browser.close()
# Run the example
asyncio.run(solve_hcaptcha_example())
const { chromium } = require("playwright");
async function solveHcaptchaExample() {
// ...
const page = await browser.contexts()[0].newPage();
// Create CDP session
const client = await page.context().newCDPSession(page);
// Navigate to page with hCaptcha
await page.goto("https://example.com/hcaptcha-page", { waitUntil: "load" });
// Set up event listeners
client.on("Captcha.solveFinished", (params) => {
console.log("hCaptcha solved successfully:", params);
});
client.on("Captcha.solveFailed", (params) => {
console.error("hCaptcha solving failed:", params);
});
// Trigger hCaptcha solving
console.log("Sending Captcha.solve command...");
await client.send("Captcha.solve", {
type: "hcaptcha",
options: {
gemini_api_key: "YOUR_GEMINI_API_KEY_HERE",
},
});
// ...
await browser.close();
}
// Run the example
solveHcaptchaExample().catch(console.error);