How to download a page in Python

If you want to download a page with Python, you will be suprised on how many ways you are able to do so. In this post I have collected two methods which will allow you to download a HTML page directly with Python.

The first one is the WGET function, this function is very direct. You first have to import wget, and afterwards you can use the‘’) function call to download the HTML page of

The second one uses the urllib library. This library allows you to download any HTML page with Python. You can use it by importing the urllib library. Once you have done that, you can create an variable which will hold the HTML page you want to download. In this case, the html variable is called html.

Download a page in Python with WGET

import wget
html ='')

Download a page in Python with URLLIB2

import urllib
response = urllib.urlopen('')
html =
Share This Message