Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 743
BiscottiGummyBears Avatar asked Jan 07 '10 21:01

BiscottiGummyBears


People also ask

Is Urllib built in Python 3?

The urllib module in Python 3 allows you access websites via your program. This opens up as many doors for your programs as the internet opens up for you. urllib in Python 3 is slightly different than urllib2 in Python 2, but they are mostly the same.


1 Answers

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

import urllib.request f = urllib.request.urlopen("http://stackoverflow.com") print(f.read()) 
like image 52
Greg Hewgill Avatar answered Sep 22 '22 09:09

Greg Hewgill