Skip to content

Instantly share code, notes, and snippets.

@goddoe
Created March 23, 2020 15:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goddoe/cbccae3042c68d79d551a6ffad8232f9 to your computer and use it in GitHub Desktop.
Save goddoe/cbccae3042c68d79d551a6ffad8232f9 to your computer and use it in GitHub Desktop.
How to use Python requests to fake a browser visit?
import requests
url = 'http://www.ichangtou.com/#company:data_000008.html'
headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'}
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