BiscottiGummyBears BiscottiGummyBears - 6 months ago 27
Python Question

Python 3 Get HTTP page

How can I get python to get the contents of an HTTP page? So far all I have is the request and I have imported http.client.

Answer

Using urllib.request is probably the easiest way to do this:

import urllib.request
f = urllib.request.urlopen("http://stackoverflow.com")
print(f.read())