我试图使用python请求检索https://donneespubliques.meteofrance.fr/donnees_libres/Txt/Synop/Archive/synop.201803.csv.gz。在
然而,当访问response的内容时,我得到的是csv数据,而不是我预期的gzip压缩的csv数据。我不清楚为什么。在
>>> url
'https://donneespubliques.meteofrance.fr/donnees_libres/Txt/Synop/Archive/synop.201803.csv.gz'
>>> resp = requests.get(url)
>>> resp.headers
{'Date': 'Thu, 19 Apr 2018 10:48:11 GMT', 'Server': 'MFWS',
'Last-Modified': 'Sat, 31 Mar 2018 21:10:09 GMT',
'ETag': '"3066bd-a2dce-568bbc81bee40"',
'Accept-Ranges': 'bytes',
'Content-Length': '667086',
'Content-Type': 'application/x-gzip',
'Content-Encoding': 'gzip',
'Content-Disposition': 'attachment',
'Keep-Alive': 'timeout=5, max=300',
'Connection': 'Keep-Alive'}
>>> resp.content[:100]
b'numer_sta;date;pmer;tend;cod_tend;dd;ff;t;td;u;vv;ww;w1;w2;n;nbas;hbas;cl;cm;ch;pres;niv_bar;geop;te'
>>> requests.__version__
'2.18.4'
如果我使用curl等访问同一个URL,则会得到预期的gzip内容:
^{pr2}$这是我不懂的请求功能吗?服务器配置错误?在
这确实是一个特性,参见here。在
相关问题 更多 >
编程相关推荐