gpt4 book ai didi

url - python中的gzip url请求

转载 作者:行者123 更新时间:2023-12-03 16:24:40 24 4
gpt4 key购买 nike

我正在使用带有请求模块的 python 从带有 json 提要的 api 获取数据。
当我包含对 gzip 的请求作为编码时,我没有看到任何变化。我在这里以错误的方式实现它吗?

my_headers = {'accept-encoding':'gzip'}
response = requests.get(url, headers=my_headers)
print(response.headers)
print(len(response.content))

响应 header 总是返回
'Content-Encoding': 'gzip'

但是无论是否包含我的请求 header 都会发生这种情况,长度和加载时间也不会改变

最佳答案

Requests: HTTP for Humans - Binary Response Content

gzip and deflate transfer-encodings are automatically decoded for you.

关于url - python中的gzip url请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50886701/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com