June 2015
Intermediate to advanced
320 pages
7h 18m
English
Let's take a closer look at our response object. We can see from the preceding example that urlopen() returns an http.client.HTTPResponse instance. The response object gives us access to the data of the requested resource, and the properties and the metadata of the response. To view the URL for the response that we received in the previous section, do this:
>>> response.url 'http://www.debian.org'
We get the data of the requested resource through a file-like interface using the readline() and read() methods. We saw the readline() method in the previous section. This is how we use the read() method:
>>> response = urlopen('http://www.debian.org') >>> response.read(50) b'g="en">\n<head>\n <meta http-equiv="Content-Type" c'
The ...
Read now
Unlock full access