O'Reilly logo

Python: Essential Reference, Third Edition by David Beazley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

urllib

The urllib module is used to fetch data from the Web. This module is relatively simple and easy to use. However, if you need more advanced capabilities, such as dealing with cookies or user authentication, you should use the urllib2 module instead.

						urlopen(url
						[,
						data])

Given the uniform resource locator url, such as ‘http://www.python.org’ or ‘ftp://foo.com/pub/foo.tar’, this function opens a network connection and returns a file-like object. If the URL doesn’t have a scheme identifier such as ftp: or http:, or if it’s file:, a local file is opened. If a connection cannot be made or an error occurs, an IOError exception is raised. If the URL is an HTTP request, the optional data argument specifies that the request should be made using ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required