
Ethan Collins
Pattern Recognition Specialist

CAPTCHA (Completely Automated Public Turing test to tell Computers and Humans Apart) is a security measure designed to distinguish human users from automated bots. It often presents challenges such as image recognition, text distortion, or interactive puzzles that are easy for humans but difficult for bots. While CAPTCHAs protect websites from automated abuse, they can be a significant hurdle for legitimate automation and web scraping activities.
In this blog, we'll explore how to solve CAPTCHAs using Playwright with the CapSolver extension. Additionally, we'll look at solving reCAPTCHA using the CapSolver API with Python and Go.
CAPTCHA is a security mechanism used by websites to prevent automated access and ensure that the user is a human. Common types include:
CapSolver is a powerful tool designed to automatically solve various types of CAPTCHAs, including captcha and reCAPTCHA. It provides browser extensions and APIs for seamless integration into your web automation workflows.
Redeem Your CapSolver Bonus Code
Boost your automation budget instantly!
Use bonus code CAPN when topping up your CapSolver account to get an extra 5% bonus on every recharge — with no limits.
Redeem it now in your CapSolver Dashboard
.
First, you need to install Playwright. You can do this via npm:
npm install playwright
./CapSolver.Browser.Extension directory at the root of your project../assets/config.json. Ensure enabledForcaptcha is set to true and set captchaMode to token for automatic solving.Example configuration change:
{
"enabledForcaptcha": true,
"captchaMode": "token"
}
Below is an example script using Playwright to solve captcha with the CapSolver extension:
const { chromium } = require('playwright');
const path = require('path');
(async () => {
const extensionPath = path.join(__dirname, 'CapSolver.Browser.Extension');
const browser = await chromium.launchPersistentContext('', {
headless: false,
args: [
`--disable-extensions-except=${extensionPath}`,
`--load-extension=${extensionPath}`
]
});
const page = await browser.newPage();
await page.goto('https://site.example');
// Locate the captcha checkbox or frame and interact accordingly
await page.waitForSelector('selector-for-captcha', { state: 'visible' });
await page.click('selector-for-captcha');
// Add additional steps as per your requirement
// ...
await browser.close();
})();
For reCAPTCHA, you can use the CapSolver API. Here are examples in Python and Go.
import requests
import time
api_key = "YOUR_API_KEY"
site_key = "6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-"
site_url = "https://www.google.com/recaptcha/api2/demo"
def capsolver():
payload = {
"clientKey": api_key,
"task": {
"type": 'ReCaptchaV2TaskProxyLess',
"websiteKey": site_key,
"websiteURL": site_url
}
}
res = requests.post("https://api.capsolver.com/createTask", json=payload)
resp = res.json()
task_id = resp.get("taskId")
if not task_id:
print("Failed to create task:", res.text)
return
print(f"Got taskId: {task_id} / Getting result...")
while True:
time.sleep(3)
payload = {"clientKey": api_key, "taskId": task_id}
res = requests.post("https://api.capsolver.com/getTaskResult", json=payload)
resp = res.json()
status = resp.get("status")
if status == "ready":
return resp.get("solution", {}).get('gRecaptchaResponse')
if status == "failed" or resp.get("errorId"):
print("Solve failed! response:", res.text)
return
token = capsolver()
print(token)
package main
import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
"time"
)
type capSolverResponse struct {
ErrorId int32 `json:"errorId"`
ErrorCode string `json:"errorCode"`
ErrorDescription string `json:"errorDescription"`
TaskId string `json:"taskId"`
Status string `json:"status"`
Solution map[string]any `json:"solution"`
}
func capSolver(ctx context.Context, apiKey string, taskData map[string]any) (*capSolverResponse, error) {
uri := "https://api.capsolver.com/createTask"
res, err := request(ctx, uri, map[string]any{
"clientKey": apiKey,
"task": taskData,
})
if err != nil {
return nil, err
}
if res.ErrorId == 1 {
return nil, errors.New(res.ErrorDescription)
}
uri = "https://api.capsolver.com/getTaskResult"
for {
select {
case <-ctx.Done():
return res, errors.New("solve timeout")
case <-time.After(time.Second):
break
}
res, err = request(ctx, uri, map[string]any{
"clientKey": apiKey,
"taskId": res.TaskId,
})
if err != nil {
return nil, err
}
if res.ErrorId == 1 {
return nil, errors.New(res.ErrorDescription)
}
if res.Status == "ready" {
return res, err
}
}
}
func request(ctx context.Context, uri string, payload interface{}) (*capSolverResponse, error) {
payloadBytes, err := json.Marshal(payload)
if err != nil {
return nil, err
}
req, err := http.NewRequestWithContext(ctx, "POST", uri, bytes.NewReader(payloadBytes))
if err != nil {
return nil, err
}
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
responseData, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
capResponse := &capSolverResponse{}
err = json.Unmarshal(responseData, capResponse)
if err != nil {
return nil, err
}
return capResponse, nil
}
func main() {
apikey := "YOUR_API_KEY"
ctx, cancel := context.WithTimeout(context.Background(), time.Second*120)
defer cancel()
res, err := capSolver(ctx, apikey, map[string]any{
"type": "ReCaptchaV2TaskProxyLess",
"websiteURL": "https://www.google.com/recaptcha/api2/demo",
"websiteKey": "6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-",
})
if err != nil {
panic(err)
}
fmt.Println(res.Solution["gRecaptchaResponse"])
}
Using tools like Playwright and CapSolver, you can automate the solving of CAPTCHAs, making web scraping and automation tasks more efficient. Whether you're dealing with captcha or reCAPTCHA, the methods outlined here provide a robust solution to overcome these challenges.
The legality of solving CAPTCHAs depends on the website’s Terms of Service, applicable local laws, and how the automation is used. CapSolver itself is a neutral tool designed for legitimate use cases such as testing, QA automation, accessibility, and authorized data collection. Before deploying any CAPTCHA-solving solution, you should ensure you have permission from the target website and that your use complies with relevant regulations.
CapSolver supports a wide range of modern CAPTCHA systems, including but not limited to:
Support is available through both browser extensions (for Playwright, Puppeteer, etc.) and API-based solutions for backend automation.
Use the CapSolver browser extension when:
Use the CapSolver API when:
In many production setups, teams combine both approaches depending on the scenario.
CapSolver is optimized for high success rates and low latency. In most cases, reCAPTCHA v2 challenges are solved within a few seconds, depending on network conditions and task complexity. For large-scale automation, CapSolver also supports concurrency and stable throughput, making it suitable for enterprise-level scraping and testing workflows.
Understand reCAPTCHA v3 score range (0.0 to 1.0), its meaning, and how to improve your score. Learn how to handle low scores and optimize user experience.

Facing "reCAPTCHA Invalid Site Key" or "invalid reCAPTCHA token" errors? Discover common causes, step-by-step fixes, and troubleshooting tips to resolve reCAPTCHA verification failed issues. Learn how to fix reCAPTCHA verification failed please try again.
