Created
October 25, 2019 14:32
-
-
Save swang373/0706dd07d912c89d43040d91fac2a9b7 to your computer and use it in GitHub Desktop.
Add User-Agent to request header
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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