版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/t8116189520/article/details/80484381
import requests
import gzip
import json
# gz文件地址
url='https://shilupan-basic-user-pro.oss-cn-shanghai.aliyuncs.com/carrier/moxie/origin/39984791325599432283.txt.gz?Expires=1527497273&OSSAccessKeyId=TMP.AQEh4F-lRNcOsquy3PtvrvhnvooWgj7QI_I5xqpA2V3-yrr0PyQtNKGRWerJADAtAhUAlpsBiOtD6FNQMF9DmtiW3ZO39owCFGME2n4KgLW0ZknE1uQ_rOAPRQoC&Signature=oOn5739IptAlhhh%2F04ckqjQFdTY%3D'
response=requests.get(url)
html=response.text
response.encoding = 'utf-8'
# 解压后为bytes类型
html1 = gzip.decompress(response.content)
print(html)
print(type(html1))
#转化成str
html2=html.decode()
print(type(html2))
# 转为json
html3=json.loads(html2)
print(html3)
print(type(html3))