There's more...

The headers in a response contain a wealth of information.  If we look more closely at the headers property of the response, we can see the following headers are returned:

>>> response = urllib.request.urlopen(const.ApodEclipseImage())>>> for header in response.headers: print(header)DateServerLast-ModifiedETagAccept-RangesContent-LengthConnectionContent-TypeStrict-Transport-Security

And we can see the values for each of these headers.

>>> for header in response.headers: print(header + " ==> " + response.headers[header])Date ==> Tue, 26 Sep 2017 19:31:41 GMTServer ==> WebServer/1.0Last-Modified ==> Thu, 31 Aug 2017 20:26:32 GMTETag ==> "547bb44-29c06-5581275ce2b86"Accept-Ranges ==> bytesContent-Length ==> 171014Connection ==> ...

Get Python Web Scraping Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.