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

源码:

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

学习是最好的投资!

reply all(1)
刘奇

That’s good

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

Maybe it’s because this website doesn’t use gzip compression

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template