热线电话:13121318867

登录
2019-04-17 阅读量: 692
IncompleteRead错误

原因:这个异常表示希望从HTTP body 中读取A 字节,但实际能够读取的字节数小于A个字节。

HTTP Response 的Header 大致如下:

{'connection': 'keep-alive', 'content-type': 'application/json', 'content-length': '44668', 'content-encoding': 'gzip'}

可以判断Response body完整传输(safe transport)的要素是 content-length,也就是说实际读到的body体的长度小于content_length。

捕获异常及处理:

	for li in lie:
try:
li_code.append(get_html(li)) #获取详情页面code
except Exception as e:
print(e)
#print(e.partial.decode('utf-8')) #捕获异常原代码
li_code.append(e.partial.decode('utf-8')) #将捕获的异常页面代码添加到列表中(此处根据实际情况更改)
continue #继续for循环
66.6667
3
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子