visit
Ever wondered how software introduces itself to servers? Enter the User-Agent
header—a digital ID that reveals crucial details about the client making an HTTP request. As you’re about to learn, setting a user agent for scraping is a must!
The User-Agent
is a automatically set by applications and libraries when making HTTP requests. It contains a string that spills the beans about your application, operating system, vendor, and the version of the software making the request.
That string is also known as a user agent or UA. But why the name “User-Agent”? Simple! In IT lingo, a is any program, library, or tool that makes web requests on your behalf.
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36
If you’re baffled by that string, you’re not alone. Why would a Chrome user agent contain words like “Mozilla” and “Safari”? 🤯
User-Agent
header here is like a detailed dossier, packing in the browser name, operating system, architecture, and sometimes even specifics about the device.
User-Agent
provide just the basics, the library name, and occasionally the version.
User-Agent
is one of the HTTP headers that these anti-bot systems scrutinize closely. After all, the string in that header helps the server understand whether a request is coming from a genuine browser with a well-known user agent string. No wonder User-Agent
is one of the most important . 🕵️♂️
The workaround to avoid blocks? Discover user agent spoofing!
Don’t forget that User-Agent
is nothing more than an HTTP header. So, you can give it whatever value you want. Changing user agent for web scraping is an old that trick helps you dodge detection and blend in as a standard browser. 🥷
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:129.0) Gecko/20100101 Firefox/129.0
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36
Mozilla/5.0 (iPhone; CPU iPhone OS 17_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/127.0.6533.107 Mobile/15E148 Safari/604.1
Mozilla/5.0 (Macintosh; Intel Mac OS X 14.6; rv:129.0) Gecko/20100101 Firefox/129.0
Mozilla/5.0 (Macintosh; Intel Mac OS X 14_6_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.5 Safari/605.1.15
Mozilla/5.0 (Macintosh; Intel Mac OS X 14_6_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 OPR/112.0.0.0
Mozilla/5.0 (iPhone; CPU iPhone OS 17_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.5 Mobile/15E148 Safari/604.1
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.6533.103 Mobile Safari/537.36
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 Edg/127.0.2651.98
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 OPR/112.0.0.0
Of course, this is just the tip of the iceberg, and the list could go on and on. For a comprehensive and up-to-date list of user agents for scraping, check out sites like and .
So, you’re thinking that just swapping your HTTP client library's default User-Agent
with one from a browser might do the trick to dodge anti-bot systems? Well, not quite…
If you’re flooding a server with requests with the same User-Agent
and from the same IP, you’re basically waving a flag that says, “Look at me, I’m a bot!” 🤖
To up your game and make it harder for those anti-bot defenses to catch on, you need to mix things up. That’s where user agent rotation comes in. Instead of using a static, real-world User-Agent
, switch it up with each request.
Collect a list of user agents: Gather a set of UA strings from various browsers and devices.
Extract a random user-agent: Write simple logic to randomly pick a user agent string from the list.
Configure your client: Set the randomly selected user agent string in the User-Agent
header of your HTTP client.
The User-Agent
header reveals details about the software and system making an HTTP request. You now know what the best user agent for web scraping is and why rotating it is crucial. But let’s face it—user agent rotation alone won’t be enough against sophisticated bot protection.