What’s the best way to get an HTTP response code from a URL?

后端 未结 7 877
有刺的猬
有刺的猬 2020-11-28 02:34

I’m looking for a quick way to get an HTTP response code from a URL (i.e. 200, 404, etc). I’m not sure which library to use.

7条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-28 02:59

    The urllib2.HTTPError exception does not contain a getcode() method. Use the code attribute instead.

提交回复
热议问题