Configures the requests library to randomly select a desktop User-Agent
Last updated Jun 19, 2026
78
Stars
23
Forks
6
Issues
0
Stars/day
Attention Score
8
Language breakdown
Python 81.3%
Makefile 18.7%
โธ Files
click to expand
README
requests-random-user-agent

Configures the requests library to randomly select a desktop User-Agent. See the full list in requestsrandomuser_agent/useragents.txt.
Installation
pip install requests-random-user-agent
Usage
python
import requests
import requestsrandomuser_agent
s = requests.Session() print(s.headers['User-Agent'])
Without a session
resp = requests.get('https://httpbin.org/user-agent')
print(resp.json()['user-agent'])
User-Agents are randomized per-session or per-request. Individual HTTP requests without a session will each have a random User-Agent selected from the list in useragents.txt.
Android User-Agents
Set the environment variable UAPLATFORM=android to use a list of Android-specific User-Agents instead. List provided by WhatIsMyBrowser.
๐ More in this category