Skip to content

Instantly share code, notes, and snippets.

@swang373
Created October 25, 2019 14:32
Show Gist options
  • Save swang373/0706dd07d912c89d43040d91fac2a9b7 to your computer and use it in GitHub Desktop.
Save swang373/0706dd07d912c89d43040d91fac2a9b7 to your computer and use it in GitHub Desktop.
Add User-Agent to request header
import requests
URL = 'https://www.google.com'
HEADERS = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:61.0) Gecko/20100101 Firefox/70.0'
}
response = requests.get(URL, headers=HEADERS)
print(response.content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment