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

源码:

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學習者快速成長!