1
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.

Rick
  • 7,007
  • 2
  • 49
  • 79
  • Have you seen [this](https://stackoverflow.com/questions/14949644/python-get-header-information-from-url). And were you actually trying getheaders or getheader? – idjaw Aug 02 '17 at 01:36
  • Also see [this](https://stackoverflow.com/questions/843392/python-get-http-headers-from-urllib2-urlopen-call) – Vinícius Figueiredo Aug 02 '17 at 01:37

0 Answers0