Captcha solving in browser sessions
Have String solve challenge pages and captchas inside pages or iframes during a browser session.
Add solveCaptcha=true to the /wss connect URL and String solves a captcha or challenge page that a navigation
lands on, so your page loads the page you asked for. A captcha inside a page or one of its iframes is solved too.
Leave it off when your code handles challenges itself, or when navigation time matters more than loading the page
behind a challenge.
Connect with solveCaptcha
import { chromium } from "playwright-core";
const browser = await chromium.connectOverCDP("wss://request.usestring.ai/v1/wss?solveCaptcha=true", {
headers: { Authorization: `Bearer ${process.env.STRING_API_KEY}` }
});
const page = await browser.contexts()[0].newPage();
const response = await page.goto("https://example.com/");
console.log(response?.status(), page.url());
await browser.close();When the navigation meets a challenge, goto stays pending while String solves it, then resolves on the page
behind it:
200 https://example.com/If the site redirects after the challenge, the navigation follows that redirect and page.url() is where it ended.
If the challenge can't be solved, the navigation resolves on the challenge page, as it would without the parameter.
Captchas inside a page
A captcha inside a page, or in an iframe such as an embedded booking or checkout form, doesn't hold the navigation.
goto resolves when the page loads, and String solves the captcha while your code carries on. Once it's solved, the
page treats it as completed, so whatever it enables next, such as a submit button, becomes ready. Wait for that
element rather than submitting straight away. Insert the following before await browser.close() in the connect
example above:
await page.goto("https://example.com/book");
const form = page.frameLocator("iframe#booking");
await form.locator("button[type=submit]:not([disabled])").click({ timeout: 150_000 });If the captcha can't be solved, it stays on the page unsolved, as it would without the parameter, and your code can complete it another way.
Rules and limits
- Off by default. Unlike on
/fetch, nothing is solved unless you setsolveCaptcha=true. - Key permission. Your API key must be allowed to solve captchas. With a key that isn't, the parameter is ignored and the session runs without solving.
- Challenge pages: top-level
GETnavigations only. A challenge page in an iframe, in afetchor XHR response, or in response to a formPOSTreaches your page unchanged. - Captchas inside a page: only frames your client is attached to. Playwright and Puppeteer attach to every frame by default; frames your client doesn't attach to keep their captchas unsolved.
- Navigation time. A challenge-page solve keeps a navigation pending for at most 22 seconds. Keep your navigation timeout at 30 seconds or more, the default in Playwright and Puppeteer.
- Captcha time. A captcha inside a page takes up to 2 minutes to solve. After 2 minutes it stays on the page unsolved, so give the step that waits on it longer than that.
- One solve at a time per session, across challenge pages and captchas inside a page. A challenge or captcha that appears during a solve reaches your page unsolved.
- 25 solve attempts per session. Failed attempts count. Later challenges in the session reach your page unchanged. Reconnect to solve more.
- Failed URLs wait 60 seconds. After a solve fails, the same URL loads its challenge page, or keeps its captcha unsolved, without a new attempt for 60 seconds.
Billing
Solving has no charge of its own. The session bills at its usual bandwidth and duration rates, and the traffic a solve uses counts toward its bandwidth.