February 2006
Intermediate to advanced
648 pages
14h 53m
English
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 ...