π©π»π»/python
[python] Received response with content-encoding: gzip, but failed to decode it.
λ°μΏλ¦¬
2024. 2. 19. 14:53
μλ¬ : Received response with content-encoding: gzip, but failed to decode it.', error('Error -3 while decompressing data: incorrect data check')
res = requests.get( page_url, headers={ 'User-Agent': utils.get_random_agent() }, timeout=10 )
content = res.content
μμ κ°μ΄ μμ²μ, μλμ κ°μ λ©μΈμ§μ ν¨κ» ν¬λ‘€λ§μ΄ μ§νμ΄ λΆκ°ν μν©μ΄ λ°μνλ€.
# error
Received response with content-encoding: gzip, but failed to decode it.', error('Error -3 while decompressing data: incorrect data check')
μ΅μ μ μΆκ°νλ€.
res = requests.get( page_url, headers={ 'User-Agent': utils.get_random_agent(), 'Accept-Encoding': 'identity' }, timeout=10, stream=True )
content = res.raw.read()
* μΆκ°λ κ²μ
1. 'Accept-Encoding': 'identity'
2. stream=True
* μμ λ κ²μ
content = res.content μΌλ‘ κ°μ§κ³ μ€λ κ² λμ content = res.raw.read() μΌλ‘ μ½μ΄μ£Όλ μ μ§νλλ κ²μ νμΈνλ€.
κ·Όλ° μ’ λλ €μ§