Making HTTP HEAD request with urllib2 from Python 2

后端 未结 4 1412
无人共我
无人共我 2020-11-27 18:51

I\'m trying to do a HEAD request of a page using Python 2.

I am trying

import misc_urllib2
.....
opender = urllib2.build_opener([misc_urllib2.MyHTTPR         


        
4条回答
  •  春和景丽
    2020-11-27 19:21

    you shoud not add HeadRequest to build_opener or add_handler it should be called like this

    opener = urllib2.build_opener(MyHTTPRedirectHandler)
    response = opener.open(HeadRequest(url))
    print response.getheaders()
    

提交回复
热议问题