当发出GET请求时
https://apicache.vudu.com/api2/?_type=contentSearch&contentEncoding=gzip&contentId={}&dimensionality=any&followup=ultraVioletability&followup=longCredits&followup=superType&followup=episodeNumberInSeason&followup=advertContentDefinitions&followup=tag&followup=hasBonusWithTagExtras&followup=subtitleTrack&followup=ratingsSummaries&followup=geneGenres&followup=seasonNumber&followup=trailerEditionId&followup=genres&followup=usefulStreamableOffers&followup=walmartOffers&followup=preOrderOffers&followup=editions&followup=merchandiseContentMaps&followup=promoTags&followup=advertEnabled&format=application%2Fjson
来自AWS,我间歇性地接收到以下错误:
ContentDecodingError: ('Received response with content-encoding: gzip, but failed to decode it.', error('Error -3 while decompressing: incorrect header check',))
示例:
requests.get(url.format('832504'))
<Response [200]>
requests.get(url.format('460398'))
<Response [200]>
requests.get(url.format('27616'))
<Response [200]>
requests.get(url.format('23657'))
<Response [200]>
requests.get(url.format('8661'))
ContentDecodingError...
requests.get(url.format('14250'))
<Response [200]>
requests.get(url.format('516307'))
ContentDecodingError...
requests.get(url.format('10366'))
<Response [200]>
我尝试过不同的标题组合(包括这里的建议:https://github.com/requests/requests/issues/3849)和删除contentEncoding=gzip
param (返回502状态代码)。
考虑到这个API在我的PC上完美无缺地工作,也许Vudu和AWS之间有一些冲突?
发布于 2020-09-05 03:00:37
我认为这是当前python请求库的限制(或设计行为,请参阅这里)。
因此,您必须使用resp.raw
来获取原始字节。(Note:要访问resp.raw
,还需要stream=True
)。
resp = session.get(url, stream=True)
data = resp.raw.read()
https://stackoverflow.com/questions/53435774
复制相似问题