主要是获取下面的json
文件,其他的可以参考另外的两篇文章:
import requests
import json
import time
url = "https://api-gateway.guahao.com/moduleoperate/operatechannel/getbyconfForPage.json"
header = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0",
"Content-Type": "application/json;charset=utf-8",
"weiyi-appid": "p_h5_weiyi"
}
def convert_timestamp(timestamp):
time_str = timestamp[:-3]
time_struct = time.localtime(int(time_str))
return time_struct
pyload = {"channelConPosition": "71"}
response = requests.post(url, headers=header, data=json.dumps(pyload))
data = response.json().get("data").get("sariAreaDataList")
for i in data:
print(convert_timestamp(i.split("|")[0]))
"""
1580969520000|1|北京|0|NULL|1|31|1|0|274|7|0|0|21
1580969520000|36|合肥|23|安徽|2|5|0|0|104|0|0|0|11
时间戳|city_id|城市|province_id|省份|2表示city,1表示省份,9表示外国|治愈人数|死亡人数||确诊人数||||
"""
# {"channelConPosition":"72","pageNumber":2,"pageSize":3,"lastDate":1580977200000}
str = "1580977200000"
print(convert_timestamp(str))