How can I perform a HEAD request with the mechanize library?

后端 未结 2 1917
半阙折子戏
半阙折子戏 2021-01-14 09:23

I know how to do a HEAD request with httplib, but I have to use mechanize for this site.

Essentially, what I need to do is grab a value from the header (filename) w

2条回答
  •  误落风尘
    2021-01-14 10:22

    In mechanize there is no need to do HeadRequest class etc.

    Simply

    
    import mechanize
    
    br = mechanize.Browser()
    
    r = br.open("http://www.example.com/")
    
    print r.info()
    
    

    That's all.

提交回复
热议问题