Python Language Simple web content download with urllib.request


Example

The standard library module urllib.request can be used to download web content:

from urllib.request import urlopen

response = urlopen('http://stackoverflow.com/questions?sort=votes')    
data = response.read()

# The received bytes should usually be decoded according the response's character set
encoding = response.info().get_content_charset()
html = data.decode(encoding)

A similar module is also available in Python 2.