NEWStandard createTask and in.php APIs. Change the address and you are connected.View API docs
GATESOLVER

Web scraping

Picking user agents for scrapers

The user agent is the first identity claim your scraper makes, and the easiest one to get wrong. The best string is current, common, true to the engine you run, and stable for the length of a session.

Why the choice matters

Every request carries a User-Agent header, and every protected site reads it. Library defaults such as python-requests/2.x or Go-http-client/1.1 announce automation outright, and many sites refuse them on sight. Replacing the default with a browser string is the obvious first step. The less obvious part is choosing a string that survives the checks that follow, because the header is compared with everything else the client reveals.

Rule one: keep it current

Browsers update every few weeks, and real traffic moves to the new version quickly. A string naming a browser release from two years ago is now rare in real traffic, which makes it stand out. Old strings copied from a blog post are one of the most common reasons a scraper that once worked starts getting challenged.

Treat your strings as configuration with an expiry date. Review them when major browser versions ship, which for Chrome and Firefox is roughly monthly. A practical approach is to read the version from the browser you actually run, or from your own site's analytics if you have one, and build the string from that. Avoid long lists scraped from the internet; they are full of stale and odd entries.

Rule two: match the engine you actually run

The string is a claim, and sites verify claims. If you run headless Chromium, claim Chrome of the same major version. If you use an HTTP client, claim the browser whose TLS handshake that client reproduces. Mismatches are easy to detect:

  • A Firefox string from a Chromium engine fails JavaScript feature checks and sends Chromium client hints that Firefox never sends.
  • A Chrome string from a plain Python or Go HTTP stack fails the TLS fingerprint check before any HTML is served.
  • A Chrome 131 string from a Chrome 120 engine misses features the claimed version would have.

The mismatched user agent entry describes how sites compare these layers.

Rule three: match the platform

The operating system in the string must agree with the platform values the browser reports: navigator.platform, the Sec-CH-UA-Platform header and navigator.userAgentData. A scraper on a Linux server claiming Windows needs those values overridden too, which browser automation can do through the DevTools protocol (shown in changing the user agent in Selenium). With a plain HTTP client, send matching client hint headers or none at all, rather than hints that contradict the string.

Desktop versus mobile is part of the platform too. A mobile string should come with a mobile viewport, touch support and a mobile layout request. If you just want the desktop page, use a desktop string; mobile strings are useful only when you deliberately want the mobile version of a site.

Rule four: choose common over clever

The safest identity is the one shared by the most real visitors. On desktop that is usually the current stable Chrome on Windows, followed by Chrome on macOS, Edge on Windows and Safari on macOS. Unusual browsers, beta channels and rare operating systems are legitimate, but each is a small crowd to hide in. Unless you have a reason, pick from the big groups.

Rotation: per session, not per request

Rotation spreads requests across identities, which helps when many independent fetches would otherwise all look the same. Done badly, it hurts. A visitor whose browser changes between Chrome on Windows and Safari on a Mac from one page to the next, with the same cookies and address, is not a real visitor.

  • Bind the string to the session. Choose a user agent when a session starts and keep it, along with the cookies and proxy address, until the session ends.
  • Keep the pool small. Five to ten current, common strings are plenty. Hundreds of variants add rare versions without adding cover.
  • Weight by popularity. Use the most common identity most often, roughly in proportion to real traffic.
  • Retire together. When a browser version ages out, remove it from the pool rather than letting it linger.
import random
from dataclasses import dataclass, field

POOL = [
    ("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
     "(KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36", 6),
    ("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 "
     "(KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36", 3),
    ("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
     "(KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0", 1),
]

@dataclass
class CrawlSession:
    proxy: str
    ua: str = field(default_factory=lambda: random.choices(
        [s for s, _ in POOL], weights=[w for _, w in POOL])[0])
    pages_left: int = 40

The version numbers above are placeholders for whatever is current when you read this; update them with the rest of your configuration.

The rest of the header set

A browser never sends the user agent alone. It sends Accept, Accept-Language, Accept-Encoding and, for Chromium, client hints and Sec-Fetch-* headers, in a typical order. A request with a perfect user agent and nothing else is incomplete. Copy the full header set your claimed browser sends for a top-level navigation, keep the language consistent with your exit location, and let an HTTP/2-capable client handle header order where it can.

Test what the site sees

Before a crawl, send a request through your full stack (client, proxy, headers) to an echo endpoint you control and read back the user agent, header order, client hints and, if your tooling allows, the TLS fingerprint. In a browser, also read navigator.userAgent and navigator.userAgentData from inside the page. Make this a test that runs whenever you change versions.

User agents and CAPTCHA answers

Many token answers include the user agent they were produced under. Tasks for reCAPTCHA v2, reCAPTCHA v3 and Cloudflare Turnstile return a userAgent next to the token, and the Cloudflare Challenge and DataDome Slider tasks accept a userAgent field whose value you must keep using with the returned cookie. Matching your session's string to that value removes a source of rejections. The short answer to what user agent to use with a token covers the details.

When an honest bot string is the better choice

Not every crawler needs to look like a browser. If a site welcomes automated visitors, publishes a crawl policy or gave you permission, a descriptive string such as ExampleCoPriceBot/1.4 (+https://example.com/bot) is the courteous option. It lets the site's operators recognize your traffic, contact you, and set a rate for you instead of blocking you. Keep that string stable, host a page at the linked address explaining what the bot collects and how to opt out, and honor robots.txt rules addressed to your bot's name. Browser strings are for sites where a generic client would be refused for reasons that have nothing to do with your intent.

What a user agent cannot fix

A good string is necessary but not sufficient. It will not fix a datacenter address with poor reputation, a TLS handshake from the wrong library, a request rate no person could produce, or a headless browser that announces itself. Use the string to remove one obvious signal, then address the others with the approaches in why a site thinks you are a bot.

Common questions

Where can I find current user agent strings?

The most reliable source is the browser you actually run: read navigator.userAgent from it. Your own site analytics also show what real visitors send.

Should I rotate user agents on every request?

No. Keep one string per session, together with its cookies and address. Changing identity between pages looks less like a real visitor, not more.

Is a mobile user agent less likely to be blocked?

Not by itself. It also requests the mobile page and must be backed by a mobile viewport and touch support, or it creates a mismatch.

Do I need client hints with an HTTP client?

Chromium sends them by default, so a Chrome string without hints is slightly unusual. Send consistent hints or use a client that reproduces Chrome fully.

How often should I update my user agent pool?

Review it whenever a major browser version ships, roughly monthly, and remove versions that have fallen out of common use.

Keep reading