Skip to content

Instantly share code, notes, and snippets.

@InputBlackBoxOutput
Created March 28, 2022 12:58
Show Gist options
  • Save InputBlackBoxOutput/ac3657bb99ea6574be965eb7ae4b3a97 to your computer and use it in GitHub Desktop.
Save InputBlackBoxOutput/ac3657bb99ea6574be965eb7ae4b3a97 to your computer and use it in GitHub Desktop.
Get the HTML source code for a webpage
import requests
headers = {
'User-Agent': "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36"
}
def get_webpage():
url = "www.google.com"
print(url)
response = requests.request("GET", url, headers=headers)
print(response.text)
get_webpage()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment