python - 使用requests获取网页源码的时候报错:failed to decode gzip
PHPz
PHPz 2017-04-17 14:22:56
0
1
2273

源码:

import requests
if __name__ == "__main__":
    url = "http://www.wnlwedu.com/"
    r = requests.get(url=url)
    print r.text

报错信息:

requests.exceptions.ContentDecodingError: ('Received response with content-encoding: gzip, but failed to decode it.', error('Error -3 while decompressing: incorrect data check',))

requests不是会自动解压gzip吗?

PHPz
PHPz

学习是最好的投资!

全部回复(1)
刘奇

这样就好了

pythonrequests.get(url=url, headers={'Accept-Encoding': ''})

可能是因为这网站没用gzip压缩吧

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!