Publish Forum topic Publish your post to the cyberwarzone forum for free and no registration!

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 wget.download(‘cyberwarzone.com’) function call to download the HTML page of cyberwarzone.com.

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 = wget.download('http://cyberwarzone.com/')

Download a page in Python with URLLIB2

import urllib
response = urllib.urlopen('http://cyberwarzone.com/')
html = response.read()

Please spread the word :)

  • RSS
  • Follow by Email
  • Facebook
  • Google+
    http://cyberwarzone.com/download-page-python/">