January 2019
Beginner to intermediate
776 pages
19h 58m
English
We would like to send a HEAD request to http://www.python.org. This will not download the content of the home page, rather it checks whether the server returns one of the valid responses, for example, OK, FOUND, MOVED PERMANENTLY, and so on.
Listing 4.6 explains checking a web page with the HEAD request as follows:
#!/usr/bin/env python # Python Network Programming Cookbook -- Chapter - 4 # This program requires Python 3.5.2 or any later version # It may run on any other version with/without modifications. # # Follow the comments inline to make it run on Python 2.7.x. import argparse import http.client # Comment out the above line and uncomment the below for Python 2.7.x. #import httplib import urllib.parse # Comment out the ...
Read now
Unlock full access