with request.urlopen('url') as f:
data = f.read()
print('Status:', f.status, f.reason)
for k, v in f.getheaders():
print('%s: %s' % (k, v))
print('Data:', data.decode('utf-8'))
I couldn't find the f.getheaders()
method which is actually urllib.response.getheaders()
. Details of urllib.response is missed in the documentation and I couldn't get more information from the source code on GitHub.