从httplib(Python 2)的文档(在Python 3中称为http.client)中:
例外 httplib.
:( 例外 http.client.
:)
的子类HTTPException
。
在服务器响应我们不理解的HTTP状态代码时引发。
>>> theurl = 'http://www.garageband.com/mp3cat/.UZCKbS6N4qk/01_Saraenglish.mp3'
>>> if theurl.startswith("http://"):
... theurl = theurl[7:]
... head = theurl[:theurl.find('/')]
... tail = theurl[theurl.find('/'):]
...
>>> head
'www.garageband.com'
>>> tail
'/mp3cat/.UZCKbS6N4qk/01_Saraenglish.mp3'
>>> response_code = 0
>>> import httplib
>>> conn = httplib.httpconnection(head)
>>> conn.request("HEAD", tail)
>>> res = conn.getresponse()
>>> res.status
302
>>> response_code = int(res.status)
我想只是仔细检查所有内容,然后重试?