How to Solve CAPTCHA in BrowserCloud with CapSolver API

Ethan Collins
Pattern Recognition Specialist
11-Aug-2025
BrowserCloud is a high-performance, cloud-based browser automation platform designed for scalable and distributed web automation. It enables developers to run hundreds of headless Chrome browsers in parallel for use cases such as web scraping, automated testing, SEO monitoring, data extraction, and content generation. With built-in support for Puppeteer, Selenium, and Playwright, BrowserCloud simplifies complex automation workflows by offering proxy rotation, session management, and real-time monitoring.
However, CAPTCHAs, bot detection systems, and advanced anti-automation measures often disrupt these browser automation tasks by demanding human-like interactions to verify authenticity. Such barriers can block scraping scripts, slow down testing pipelines, and break automated form submissions, resulting in wasted time and reduced efficiency.
CapSolver, an AI-powered CAPTCHA-solving and bot detection bypass service, provides a reliable solution. It programmatically detects and solves a wide range of CAPTCHA types¡ªincluding reCAPTCHA v2/v3, Cloudflare Turnstile, and image-based puzzles¡ªensuring uninterrupted browser automation workflows.
In this article, we¡¯ll provide a step-by-step integration guide for connecting CapSolver with BrowserCloud using Puppeteer, along with a fully working code example. By following this guide, you¡¯ll be able to seamlessly bypass CAPTCHA challenges, defeat anti-bot measures, and maximize the efficiency of your automation scripts.
BrowserCloud Overview & Use Cases
BrowserCloud is a versatile platform that manages a grid of full-featured Chrome browsers on high-performance infrastructure, eliminating the need to handle local browser dependencies, memory leaks, or infrastructure maintenance. Its key features include:
- Scalability: Run up to 100 headless browsers simultaneously for parallel processing.
- Framework Support: Compatible with Puppeteer, Selenium, and Playwright for flexible automation.
- Proxy Management: Offers smart proxy rotation and premium proxies to avoid detection and IP bans.
- Content Generation: Generate PDFs, screenshots, and images from web pages or custom HTML via API.
- Real-Time Monitoring: Provides tools for session management and debugging.
Use Cases
BrowserCloud supports a range of automation tasks, including:
- Web Scraping: Extract data from websites for market research, price monitoring, or content aggregation, leveraging proxy support to avoid blocks.
- Automated Testing: Conduct end-to-end testing across multiple browsers and configurations to ensure application reliability.
- Content Rendering: Create thousands of PDF reports, invoices, or automated screenshots from URLs for reporting or marketing purposes.
- Task Automation: Automate repetitive tasks like form submissions, account logins, or link validation.
These use cases often encounter CAPTCHAs, making CapSolver¡¯s integration essential for uninterrupted automation.
Why CAPTCHA Solving is Needed
Websites deploy CAPTCHAs and anti-bot defenses to protect against automated access, spam, and malicious activities, posing a significant challenge for automation tasks like web scraping. CAPTCHAs require interactions such as clicking checkboxes or solving image puzzles, which can halt BrowserCloud scripts if not addressed. Common CAPTCHA types include:
CAPTCHA Type | Description |
---|---|
reCAPTCHA v2 | Requires users to check a box or select images based on a prompt. |
reCAPTCHA v3 | Uses a scoring system to assess user behavior, often invisible to users. |
Cloudflare Turnstile | A privacy-focused CAPTCHA alternative that minimizes user interaction. |
For web scraping and other automation tasks, CAPTCHAs can prevent access to critical data, requiring manual intervention that defeats the purpose of automation. While BrowserCloud¡¯s proxy rotation helps reduce CAPTCHA triggers, it may not eliminate them entirely. CapSolver¡¯s API provides a reliable solution by solving CAPTCHAs programmatically, allowing BrowserCloud scripts to bypass these barriers and continue extracting data or performing tasks seamlessly.
How to Use CapSolver to Handle CAPTCHAs
CapSolver¡¯s API can be integrated with BrowserCloud within a Puppeteer/Playwright/Selenium script to handle CAPTCHAs effectively. The process involves:
- Detecting the CAPTCHA: Identify the presence of a CAPTCHA on the page, such as a reCAPTCHA element.
- Extracting Information: Retrieve necessary details, like the site key and page URL, required for CAPTCHA solving.
- Calling CapSolver¡¯s API: Send a request to CapSolver to create a task and obtain a solution token.
- Injecting the Solution: Insert the token into the page to bypass the CAPTCHA.
- Continuing Automation: Proceed with tasks like form submission or data scraping.
This integration leverages BrowserCloud¡¯s scalable browser infrastructure and CapSolver¡¯s AI-driven CAPTCHA-solving capabilities to ensure robust automation workflows.
Complete Code Example + Step-by-Step Explanation
Below is a complete code example that demonstrates how to integrate CapSolver with BrowserCloud to solve a reCAPTCHA v2 on a demo page. The code is based on the provided script, with minor improvements for clarity and reliability.
Prerequisites
Install the required dependencies:
bash
npm install puppeteer node-fetch@2 dotenv
Create a .env
file with your API keys:
env
BROWSER_CLOUD_TOKEN=your_browsercloud_token
CAPSOLVER_API_KEY=your_capsolver_api_key
Code Example
javascript
import puppeteer from 'puppeteer';
import fetch from 'node-fetch';
import dotenv from 'dotenv';
dotenv.config();
const BROWSER_CLOUD_TOKEN = process.env.BROWSER_CLOUD_TOKEN;
const CAPSOLVER_API_KEY = process.env.CAPSOLVER_API_KEY;
async function solveCaptcha(sitekey, pageUrl) {
const createTaskRes = await fetch('https://api.capsolver.com/createTask', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
clientKey: CAPSOLVER_API_KEY,
task: {
type: 'ReCaptchaV2TaskProxyless',
websiteURL: pageUrl,
websiteKey: sitekey
}
})
});
const createTask = await createTaskRes.json();
if (!createTask.taskId) throw new Error(`CapSolver: Failed to create task: ${JSON.stringify(createTask)}`);
let solution = null;
while (true) {
await new Promise(resolve => setTimeout(resolve, 2000));
const resultRes = await fetch('https://api.capsolver.com/getTaskResult', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
clientKey: CAPSOLVER_API_KEY,
taskId: createTask.taskId
})
});
const result = await resultRes.json();
if (result.status === 'ready') {
solution = result.solution.gRecaptchaResponse;
break;
}
if (result.status === 'failed') throw new Error(`CapSolver: Failed to solve: ${JSON.stringify(result)}`);
}
if (!solution) throw new Error('CapSolver: Timeout waiting for solution');
return solution;
}
(async () => {
try {
const browser = await puppeteer.connect({
browserWSEndpoint: `wss://chrome-v2.browsercloud.io?token=${BROWSER_CLOUD_TOKEN}`
});
const page = await browser.newPage();
await page.goto('https://recaptcha-demo.appspot.com/recaptcha-v2-checkbox.php', { waitUntil: 'networkidle2' });
const sitekey = await page.$eval('.g-recaptcha', el => el.getAttribute('data-sitekey'));
console.log('Sitekey:', sitekey);
const solution = await solveCaptcha(sitekey, page.url());
console.log('CAPTCHA solution:', solution);
await page.evaluate(token => {
const textarea = document.getElementById('g-recaptcha-response');
if (textarea) {
textarea.value = token;
textarea.innerHTML = token;
textarea.style.display = '';
textarea.dispatchEvent(new Event('input', { bubbles: true }));
}
}, solution);
const submitBtn = await page.$('body > main > form > fieldset > button');
if (submitBtn) {
await Promise.all([
page.waitForNavigation({ waitUntil: 'networkidle2' }),
submitBtn.click()
]);
console.log('Submit button clicked!');
} else {
console.log('Submit button not found!');
}
console.log('Page content after submission:', await page.content());
await browser.close();
} catch (error) {
console.error('Error:', error);
}
})();
Step-by-Step Explanation
Step | Description |
---|---|
1. Set Up Environment | Install puppeteer , node-fetch@2 , and dotenv using npm. Create a .env file with your BrowserCloud and CapSolver API keys. |
2. Define solveCaptcha Function | The function takes the site key and page URL, creates a CapSolver task for reCAPTCHA v2, polls for the solution (up to 30 attempts with 2-second intervals), and returns the solution token. |
3. Connect to BrowserCloud | Use puppeteer.connect with the BrowserCloud WebSocket endpoint, including your API token. Note that createIncognitoBrowserContext is not supported in BrowserCloud¡¯s remote mode, so use browser.newPage() directly. |
4. Navigate to Target Page | Open a new page and navigate to the demo page with reCAPTCHA v2, waiting for the network to be idle. |
5. Extract Site Key | Use page.$eval to retrieve the data-sitekey attribute from the .g-recaptcha element. |
6. Solve CAPTCHA | Call solveCaptcha with the site key and page URL to obtain the solution token from CapSolver. |
7. Inject Solution | Inject the solution token into the g-recaptcha-response textarea and dispatch an input event to simulate user interaction. |
8. Submit Form | Locate the submit button, click it, and wait for navigation to ensure the form submission is processed. |
9. Verify Result | Print the page content to confirm successful submission. |
10. Close Browser | Close the browser connection to free resources. |
Note: The original code used page.waitForTimeout(3000)
after clicking the submit button, which may not reliably wait for navigation. This example improves it by using page.waitForNavigation()
to ensure the page has fully loaded after submission.
Demo Walkthrough
This section describes the script¡¯s execution on a demo page with a reCAPTCHA v2 checkbox:
- Connect to BrowserCloud: The script establishes a connection to a BrowserCloud browser instance using Puppeteer.
- Navigate to Demo Page: It loads the reCAPTCHA v2 demo page (https://recaptcha-demo.appspot.com/recaptcha-v2-checkbox.php).
- Detect and Extract Site Key: The script identifies the reCAPTCHA element and extracts its site key.
- Solve CAPTCHA: It sends the site key and page URL to CapSolver, receiving a solution token after polling.
- Inject Token: The token is injected into the
g-recaptcha-response
textarea, simulating a successful CAPTCHA verification. - Submit Form: The script clicks the submit button, triggering form submission.
- Verify Success: After navigation, the page content is logged, showing a successful submission (e.g., a confirmation message).
In practice, you would observe the browser navigating to the demo page, the reCAPTCHA checkbox being marked automatically, and the form submitting successfully, all without manual intervention.
FAQ Section
Question | Answer |
---|---|
What types of CAPTCHAs does CapSolver support? | CapSolver supports reCAPTCHA v2/v3, Cloudflare Turnstile and more. See CapSolver documentation for details. |
How do I get API keys for BrowserCloud and CapSolver? | Sign up at BrowserCloud and CapSolver to obtain your API keys after registration. |
Can I use this integration with Selenium or Playwright? | Yes, you can adapt the integration for Selenium or Playwright by modifying the browser control and page manipulation logic to match those frameworks¡¯ APIs. |
What if CapSolver fails to solve the CAPTCHA? | Implement retry logic in your script or check your CapSolver account for issues like insufficient balance. Log errors for debugging. |
Do I need proxies with CapSolver? | The example uses ReCaptchaV2TaskProxyless , but proxies may be needed for region-specific CAPTCHAs. BrowserCloud¡¯s built-in proxy rotation can complement this. |
Conclusion
Integrating CapSolver with BrowserCloud creates a powerful combination for automating web tasks that encounter CAPTCHAs. CapSolver¡¯s AI-driven CAPTCHA solving ensures that your Puppeteer scripts on BrowserCloud can bypass anti-bot measures, while BrowserCloud¡¯s scalable infrastructure and proxy support enhance automation reliability. This is particularly valuable for web scraping, automated testing, and content generation, where CAPTCHAs are common obstacles.
To get started, sign up for BrowserCloud and CapSolver, obtain your API keys, and implement the provided code example. Explore the CapSolver documentation and BrowserCloud documentation for advanced features and additional task types. Try this integration in your next automation project and experience seamless, uninterrupted workflows!
Bonus for Browser-use Users: Use the promo code BROWSERCLOUD when recharging your CapSolver account and receive an exclusive 6% bonus credit¡ªno limits, no expiration.
Supported Browsers and Tools
- BrowserCloud: Supports Puppeteer, Selenium, and Playwright, running Chrome browsers.
- CapSolver: Compatible with any HTTP-capable client, including browser extensions for Chrome and Firefox.
References
- BrowserCloud Official Website
- CapSolver Official Website
- Puppeteer Documentation
- CapSolver API Documentation
Compliance Disclaimer: The information provided on this blog is for informational purposes only. CapSolver is committed to compliance with all applicable laws and regulations. The use of the CapSolver network for illegal, fraudulent, or abusive activities is strictly prohibited and will be investigated. Our captcha-solving solutions enhance user experience while ensuring 100% compliance in helping solve captcha difficulties during public data crawling. We encourage responsible use of our services. For more information, please visit our Terms of Service and Privacy Policy.
More

How to Solve Captcha in Crawl4AI with CapSolver Integration
Seamless web scraping with Crawl4AI & CapSolver: Automated CAPTCHA solution, enhanced efficiency, and robust data extraction for AI.

Lucas Mitchell
26-Sep-2025

What is the best AWS WAF Solver while web scraping in 2025
Learn how to solve AWS WAF CAPTCHA efficiently with CapSolver in 2025. Step-by-step guide, Python integration, AI-powered solver to boost your automation workflow. Overcome dynamic tokens, behavioral analysis, and complex CAPTCHA challenges with ease.

Lucas Mitchell
26-Sep-2025

Solving AWS WAF Bot Protection: Advanced Strategies and CapSolver Integration
Discover advanced strategies for AWS WAF bot protection, including custom rules and CapSolver integration for seamless CAPTCHA solution in compliant business scenarios. Safeguard your web applications effectively.

Lucas Mitchell
23-Sep-2025

How to Solve AWS WAF Challenges with CapSolver: The Complete Guide in 2025
Master AWS WAF challenges with CapSolver in 2025. This complete guide offers 10 detailed solutions, code examples, and expert strategies for seamless web scraping and data extraction.

Lucas Mitchell
19-Sep-2025

What is AWS WAF: A Python Web Scraper's Guide to Seamless Data Extraction
Learn how to effectively solve AWS WAF challenges in web scraping using Python and CapSolver. This comprehensive guide covers token-based and recognition-based solutions, advanced strategies, and code examples fo easy data extraction.

Lucas Mitchell
19-Sep-2025

How to Solve AWS WAF Captcha When Web Scraping: A Compenhensive Guide
Solve AWS WAF Captcha in web scraping with CapSolver. Boost efficiency, solve challenges, and keep data flowing seamlessly.

Lucas Mitchell
17-Sep-2025