Learning Python Network Programming
HTTP and Working with the Web ... print('reason', e.reason) ... print('url', e.url) status: 404 reason: Not Found url: http://ww ...
Chapter 2 Host: http://www.debian.com Connection: close User-Agent: Python-urllib/3.4 The first line is called the request line. ...
HTTP and Working with the Web Do the following to view a response object's headers: response = urlopen('http://www.debian.org ...
Chapter 2 We can check if the response is in Swedish by printing out the first few lines: response.readlines()[:5] [b'< ...
HTTP and Working with the Web Content compression The Accept-Encoding request header and the Content-Encoding response header ca ...
Chapter 2 b'', b' ', b' Debian -- The Universal Operating System '] Encodings are registered with IANA. The current list contain ...
HTTP and Working with the Web The q value follows the encoding name, and it is separated by a semicolon. The maximum q value is ...
Chapter 2 There are registered media types for many of the types of data that are transmitted across the Internet, some common o ...
HTTP and Working with the Web Then, we check the Content-Type value of our response, and extract the character set: format, p ...
Chapter 2 Here, we have created a request and submitted it using urlopen, and urlopen added the user agent header to the request ...
HTTP and Working with the Web Cookies are necessary because the server has no other way of tracking a client between requests. H ...
Chapter 2 Know your cookies It's worth looking at the properties of cookies in more detail. Let's examine the cookies that GitHu ...
HTTP and Working with the Web So, our cookie will expire on 22nd of April, 2035. An expiry date is the amount of time that the s ...
Chapter 2 Redirects Sometimes servers move their content around. They also make some content obsolete and put up new stuff in a ...
HTTP and Working with the Web Since urllib follows redirects for us, they generally don't affect us, but it's worth knowing that ...
Chapter 2 Port numbers can be specified explicitly in a URL by appending them to the host. They are separated from the host by a ...
HTTP and Working with the Web Suppose that we've retrieved the http://www.debian.org URL, and within the webpage source code we ...
Chapter 2 It work as we'd expect it to. Note the difference between the base URL having and not having a trailing slash. Lastly, ...
HTTP and Working with the Web The parse_qs() method reads the query string and then converts it into a dictionary. See how the d ...
Chapter 2 The full rules for where the reserved characters need to be escaped are given in RFC 3986, however urllib provides us ...
«
1
2
3
4
5
6
7
8
9
10
»
Free download pdf