Skip to content

Instantly share code, notes, and snippets.

@tadaoisgod
Last active February 13, 2023 19:05
Show Gist options
  • Save tadaoisgod/e5d91c8da80b083c64a4dafc0c2bdc0d to your computer and use it in GitHub Desktop.
Save tadaoisgod/e5d91c8da80b083c64a4dafc0c2bdc0d to your computer and use it in GitHub Desktop.
How to add user agents to a request in Python
import requests
url = 'https://www.whatsmyua.info/'
headers = {
'User-Agent': (
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 '
'(KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36'
),
}
response = requests.get(url, headers=headers)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment