
Anh Tuan
Data Science Expert
A User Agent (UA) is a string sent by your browser or client to identify itself to the server. It typically includes details like the browser name, version, operating system, and device type. For example:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36.
Cloudflare analyzes this string to detect bots. If your UA matches known automation tools (e.g., Python-Requests or HeadlessChrome), you’ll trigger Cloudflare’s anti-bot systems.
Before customizing, check what User Agents real users of the site are using. Tools like WhatIsMyBrowser or browser developer tools (Network tab > Headers) can help. For example, if the site is popular with Chrome users, mimic their UA.
Here’s how to modify the UA in popular programming languages:
import requests
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'
}
response = requests.get('https://example.com', headers=headers)
const axios = require('axios');
axios.get('https://example.com', {
headers: {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'
}
});
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36');
await page.goto('https://example.com');
})();
Using the same UA repeatedly can still flag you. Rotate UAs from a predefined list to mimic diverse users. Tools like Fake UserAgent simplify this:
from fake_useragent import UserAgent
import requests
ua = UserAgent()
headers = {'User-Agent': ua.random}
response = requests.get('https://example.com', headers=headers)
Using Outdated User Agents
Cloudflare maintains lists of suspicious UAs. Avoid strings tied to old browser versions (e.g., Chrome/58.0.3029.110 from 2017).
Ignoring Headless Browser Fingerprints
Even with a valid UA, headless browsers leak automation signals (e.g., missing plugins like navigator.plugins). Use stealth plugins like puppeteer-extra-plugin-stealth.
Forgetting IP Rotation
Pair UA rotation with residential proxies to avoid IP-based blocks. Static or sticky proxies work best for maintaining session consistency.
Combine with TLS Fingerprinting
Cloudflare checks TLS handshake patterns. Libraries like curl_cffi (Python) or tls-client (JavaScript) mimic real browser TLS fingerprints, reducing detection risk.
Changing your User Agent is a simple yet powerful way to bypass Cloudflare, but it’s not foolproof. Combine it with IP rotation, TLS fingerprinting, and anti-detection tools for robust results.
Happy scraping! 🤖
TL;DR - Marketplace price monitoring automation needs a stable product-region key before promotion prices can be compared. - A price change is valid only when currency, unit, promotion conditions, inventory state, and timestamp are captured together. - CAPTCHA recovery should pause one authorized job, preserve its context, run once, and return to the same product observation. - Traffic controls should reduce concurrency during rising challenge, 429, timeout, or duplicate-content rates. Introduct

TL;DR - An ai agent captcha timeout error needs separate budgets for page readiness, tool transport, CAPTCHA work, and application confirmation. - Late results must be discarded when the page URL, browser context, challenge, or authorized action has changed. - One bounded retry may be reasonable for a transient transport failure, but repeated checkpoints should open a review path. - The final pass condition is the original application state, never the absence of a thrown exception. Introduction
