Skip to content

Instantly share code, notes, and snippets.

@allenyang79
Last active August 3, 2017 09:29
Show Gist options
  • Save allenyang79/e1c16de284c7d7776b71178220ff67bf to your computer and use it in GitHub Desktop.
Save allenyang79/e1c16de284c7d7776b71178220ff67bf to your computer and use it in GitHub Desktop.
basic http request.
# Import packages
from urllib.request import urlopen, Request
# Specify the url
url = "http://docs.datacamp.com/teach/"
# This packages the request
request = Request(url)
# Sends the request and catches the response: response
response = urlopen(request)
# Extract the response: html
html = response.read()
# Print the html
print(html)
# Be polite and close the response!
response.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment