Skip to main content

Automatically generate a random User Agent for the requests library

Project description

requests-random-user-agent Build Status PyPI

Configures the requests library to randomly select a desktop User-Agent. See the full list in requests_random_user_agent/useragents.txt.

Installation

pip install requests-random-user-agent

Usage

import requests
import requests_random_user_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 UA_PLATFORM=android to use a list of Android-specific User-Agents instead. List provided by WhatIsMyBrowser.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

requests_random_user_agent-2022.1.17.tar.gz (45.3 kB view details)

Uploaded Source

File details

Details for the file requests_random_user_agent-2022.1.17.tar.gz.

File metadata

  • Download URL: requests_random_user_agent-2022.1.17.tar.gz
  • Upload date:
  • Size: 45.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for requests_random_user_agent-2022.1.17.tar.gz
Algorithm Hash digest
SHA256 a5ee84d502318a0295139b86938397286460fd200637419c2a71de036e3bf90a
MD5 ff2df5b99162f1bea1549cbfb742635b
BLAKE2b-256 df22a43a3f24ec3cffbcf48a4a9a9de5681dfb6ae7b1067c128b5044be10ad66

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page