Last active
August 3, 2017 09:29
-
-
Save allenyang79/e1c16de284c7d7776b71178220ff67bf to your computer and use it in GitHub Desktop.
basic http request.
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 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