I was looking into python urllib2 download size question.
Although the method RanRag or jterrace
suggested worked fine for me but I was wondering how to use the urllib2.Request.get_header method to achieve the same. So, I tried the below line of code:
>>> import urllib2
>>> req_info = urllib2.Request('http://mirror01.th.ifl.net/releases//precise/ubuntu-12.04-desktop-i386.iso')
>>> req_info.header_items()
[]
>>> req_info.get_header('Content-Length')
>>>
As, you can see the get_header
returned nothing and neither does header_items
.
So, what is the correct way to use the above methods?
See Question&Answers more detail:os