3.3 KiB
3.3 KiB
CAPTCHA Solver Skill
Overview
Solve CAPTCHAs using multiple approaches:
- Capsolver API - Fast, reliable, paid ($0.001-0.003/solve)
- Gemini Vision - Free, for image CAPTCHAs
- 2Captcha - Backup, $1/1000 solves
Setup
Option 1: Capsolver (Recommended)
# Sign up at https://dashboard.capsolver.com
export CAPSOLVER_API_KEY="your_key_here"
Option 2: 2Captcha
npm install @2captcha/captcha-solver
export TWOCAPTCHA_API_KEY="your_key_here"
Usage
For reCAPTCHA v2 (checkbox/invisible)
# Using Capsolver
curl -X POST https://api.capsolver.com/createTask \
-H "Content-Type: application/json" \
-d '{
"clientKey": "'$CAPSOLVER_API_KEY'",
"task": {
"type": "ReCaptchaV2TaskProxyLess",
"websiteURL": "https://example.com",
"websiteKey": "6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-"
}
}'
For Image CAPTCHA (using Gemini)
# Screenshot the CAPTCHA
agent-browser screenshot /tmp/captcha.png
# Use Gemini to solve
gemini "Look at this CAPTCHA image and tell me exactly what text/numbers are shown. Be precise." --image /tmp/captcha.png
For hCaptcha
curl -X POST https://api.capsolver.com/createTask \
-H "Content-Type: application/json" \
-d '{
"clientKey": "'$CAPSOLVER_API_KEY'",
"task": {
"type": "HCaptchaTaskProxyLess",
"websiteURL": "https://example.com",
"websiteKey": "your_hcaptcha_site_key"
}
}'
Workflow for Browser Automation
- Detect CAPTCHA - Screenshot page, check for CAPTCHA elements
- Extract Parameters - Get sitekey from page source
- Solve via API - Send to Capsolver/2Captcha
- Inject Token - Use JavaScript to set the response token
- Submit Form - Continue automation
Example: Solving reCAPTCHA in agent-browser
# 1. Get the sitekey from the page
SITEKEY=$(agent-browser eval 'document.querySelector("[data-sitekey]")?.getAttribute("data-sitekey") || document.querySelector(".g-recaptcha")?.getAttribute("data-sitekey")' 2>&1)
# 2. Get current URL
URL=$(agent-browser get url 2>&1)
# 3. Solve via Capsolver
TASK_RESPONSE=$(curl -s -X POST https://api.capsolver.com/createTask \
-H "Content-Type: application/json" \
-d '{
"clientKey": "'$CAPSOLVER_API_KEY'",
"task": {
"type": "ReCaptchaV2TaskProxyLess",
"websiteURL": "'$URL'",
"websiteKey": "'$SITEKEY'"
}
}')
TASK_ID=$(echo $TASK_RESPONSE | jq -r '.taskId')
# 4. Poll for result (typically 10-30 seconds)
sleep 15
RESULT=$(curl -s -X POST https://api.capsolver.com/getTaskResult \
-H "Content-Type: application/json" \
-d '{
"clientKey": "'$CAPSOLVER_API_KEY'",
"taskId": "'$TASK_ID'"
}')
TOKEN=$(echo $RESULT | jq -r '.solution.gRecaptchaResponse')
# 5. Inject the token into the page
agent-browser eval 'document.getElementById("g-recaptcha-response").innerHTML = "'$TOKEN'"'
# 6. Submit the form
agent-browser click "submit-button"
Pricing Reference
- Capsolver: ~$0.80-2.00 per 1000 reCAPTCHA v2
- 2Captcha: ~$1.00 per 1000 standard CAPTCHAs
- Gemini: Free (but slower, for images only)
Tips
- Use residential proxies to reduce CAPTCHA frequency
- Add human-like delays between actions
- Randomize mouse movements and typing speed
- Use browser profiles with cookies/history
- Try OAuth/SSO first - often bypasses CAPTCHA