Guides

How to Solve reCAPTCHA While Scraping: SocksNode Proxies + CaptchaAI

Keep one residential IP with a sticky SocksNode session, solve reCAPTCHA v2 with CaptchaAI, and submit the token from the same IP. A complete Python guide.

By SocksNode TeamPublished Oct 20, 20265 min read

Illustration: a browser verification puzzle solved by a robot arm, linked to a home connection

How to Solve reCAPTCHA While Scraping: SocksNode Proxies + CaptchaAI

Captchas are the most common wall a scraper hits after a few hundred requests. This guide shows the setup that gets past them reliably: a residential proxy that keeps one home IP for the whole task, and CaptchaAI to solve the reCAPTCHA when it does appear. The code is plain Python with requests, and every parameter comes from the two services' own documentation.

Why captchas appear in the first place

A site shows a captcha when a visitor looks automated. The signals it weighs are mostly about the connection:

  • The IP's owner. Addresses registered to hosting companies and cloud providers are treated as servers. Datacenter IPs see far more challenges than home IPs.
  • The IP's history. An address that sent thousands of requests an hour ago, or that is on a public proxy list, starts with a bad score.
  • Consistency. A session that changes IP between loading a page and submitting its form looks like two different visitors, which is exactly what bots do.

So the first fix is the proxy, not the solver. Real home IPs from a residential pool trigger fewer captchas, and a sticky session keeps the visitor consistent. The solver then handles the captchas that remain.

What you need

  • SocksNode residential bandwidth. Plans start at 5 GB and the bandwidth never expires. Generate proxy lines in the dashboard; generating them is free.
  • A CaptchaAI API key. CaptchaAI prices by concurrent threads with unlimited solves, from $15 a month. SocksNode users get up to 15% off through this link.
  • Python 3 with the requests package.

Step 1: a sticky proxy for the whole task

On SocksNode, port 10000 (HTTP) and 12000 (SOCKS5) hold one IP for a session. You choose the session and how long it lasts in the username:

Host:     global.socksnode.com
Port:     10000
Username: USERNAME-country-us-session-a1b2c3d4-lifetime-10
Password: your proxy password

session-a1b2c3d4 is any ID you make up; reuse it to keep the same IP, change it to get a new one. lifetime-10 keeps the address for 10 minutes, long enough to load a page, solve its captcha and submit. You can also add a city or an ISP to the username, for example USERNAME-country-us-city-chicago-session-a1b2c3d4-lifetime-10.

Step 2: load the page and read the site key

reCAPTCHA v2 is identified by a site key, found in the page's HTML as data-sitekey="..." (or as the k parameter of the reCAPTCHA iframe's URL). Load the page through the proxy and extract it.

Step 3: send the captcha to CaptchaAI

CaptchaAI takes the task at https://ocr.captchaai.com/in.php with these parameters:

  • key: your CaptchaAI API key
  • method: userrecaptcha
  • googlekey: the site key from step 2
  • pageurl: the full URL of the page (the iframe's URL if the captcha sits in an iframe)
  • json: 1 for a JSON answer

It answers with "status": 1 and a task ID in "request".

Step 4: poll for the token

Ask https://ocr.captchaai.com/res.php with key, action=get, the task id and json=1. CaptchaAI recommends waiting 15 to 20 seconds before the first check and 5 seconds between later checks while the answer is CAPCHA_NOT_READY. When it is ready, "request" holds the token.

Step 5: submit from the same session

Put the token in the g-recaptcha-response field and submit the form through the same proxy session, so the site sees one visitor from start to finish.

The complete script

import re
import time

import requests

PROXY = "http://USERNAME-country-us-session-a1b2c3d4-lifetime-10:[email protected]:10000"
CAPTCHAAI_KEY = "YOUR_CAPTCHAAI_API_KEY"
PAGE_URL = "https://example.com/login"

# One session = one cookie jar and one sticky home IP for the whole task.
session = requests.Session()
session.proxies = {"http": PROXY, "https": PROXY}
session.headers["User-Agent"] = (
    "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
    "(KHTML, like Gecko) Chrome/126.0 Safari/537.36"
)

# 1. Load the page through the proxy and read the reCAPTCHA site key.
html = session.get(PAGE_URL, timeout=30).text
sitekey = re.search(r'data-sitekey="([^"]+)"', html).group(1)

# 2. Send the captcha to CaptchaAI.
task = requests.get(
    "https://ocr.captchaai.com/in.php",
    params={"key": CAPTCHAAI_KEY, "method": "userrecaptcha",
            "googlekey": sitekey, "pageurl": PAGE_URL, "json": 1},
    timeout=30,
).json()
if task["status"] != 1:
    raise RuntimeError(f"CaptchaAI refused the task: {task['request']}")
task_id = task["request"]

# 3. Poll for the token: 15-20 s first, then every 5 s.
time.sleep(15)
while True:
    result = requests.get(
        "https://ocr.captchaai.com/res.php",
        params={"key": CAPTCHAAI_KEY, "action": "get", "id": task_id, "json": 1},
        timeout=30,
    ).json()
    if result["status"] == 1:
        token = result["request"]
        break
    if result["request"] != "CAPCHA_NOT_READY":
        raise RuntimeError(f"CaptchaAI error: {result['request']}")
    time.sleep(5)

# 4. Submit the form from the same proxy session.
response = session.post(
    PAGE_URL,
    data={"username": "your-user", "password": "your-password",
          "g-recaptcha-response": token},
    timeout=30,
)
print(response.status_code)

The calls to CaptchaAI itself do not need the proxy; only the requests to the target site do.

When to give the proxy to CaptchaAI as well

Some sites check that the IP which solved the captcha is the IP that submits it. Pages behind Cloudflare or DataDome often do. For those, pass the same SocksNode proxy to CaptchaAI with two more parameters on in.php:

  • proxy: login:password@host:port, for example USERNAME-country-us-session-a1b2c3d4-lifetime-10:[email protected]:10000
  • proxytype: HTTP, HTTPS, SOCKS4 or SOCKS5

CaptchaAI turns proxy use on for an account on request, and it recommends using it only when the site actually checks, since solving without a proxy is faster. Proxies are supported for reCAPTCHA v2, not for v3.

Tips for fewer captchas

  • Use residential, not datacenter, for strict sites. Datacenter proxies are cheaper per GB but meet more challenges.
  • One task, one session. Start each new task with a new session ID instead of reusing one IP for hours.
  • Target the right place. A US site expects US visitors; add the country (and, if it matters, the city) to the username.
  • Slow down. Spreading requests over time does more than any solver to keep captchas rare.
  • Stay within the rules. Collect only public data, respect each site's terms and the law, and never use a solver to get into accounts that are not yours.

Summary

Residential proxies prevent most captchas; a sticky session keeps the visitor consistent; CaptchaAI solves the rest; and submitting the token from the same IP is what makes it count. SocksNode bandwidth never expires, so you pay only for the traffic you use, and CaptchaAI's unlimited-solve plans cost the same whether a job meets ten captchas or ten thousand.

Frequently asked questions

Do residential proxies stop captchas completely?

No, but they make them much rarer. Home IPs and a consistent session avoid most challenges, and a solver such as CaptchaAI handles the ones that still appear.

Which SocksNode port should I use with CaptchaAI?

A sticky port: 10000 for HTTP or 12000 for SOCKS5, with a session ID and a lifetime in the username, so the page, the solve and the submit all come from one IP.

Do I have to give my proxy to CaptchaAI?

Only when the site checks that the solver's IP matches the visitor's, as pages behind Cloudflare or DataDome often do. CaptchaAI enables proxy use on request, and supports it for reCAPTCHA v2 but not v3.

How long should the sticky session last?

Long enough to load the page, solve the captcha and submit: 10 minutes is usually plenty. SocksNode sessions can last from 1 minute up to 24 hours.

How much does this setup cost?

SocksNode residential bandwidth starts at 5 GB and never expires. CaptchaAI starts at $15 a month for 5 concurrent threads with unlimited solves, and SocksNode users get up to 15% off through the link in this guide.

Related posts