这里指定了一个链接地址:
https://api.inews.qq.com/newsqa/v1/automation/modules/list?modules=FAutoforeignList
代码如下:
# 请求头
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36'
}
url = 'https://api.inews.qq.com/newsqa/v1/automation/modules/list?modules=FAutoforeignList'
# 模拟cookid
# 破解封cookid反爬机制
sess = requests.Session()
# 破解封IP反爬机制
r = sess.get(url=url, headers=headers, proxies={
"https://": '222.110.147.50:3128'}).text
res = json.loads(r, strict=False)['data']
res_list = res['FAutoforeignList']
#国家名字
list_name = []
#大陆名字
list_continent = []
#日期
list_date = []
#新增确诊
list_confirmAdd = []
#累计确诊
list_confirm = []
#疑似
list_suspect = []
#累计死亡
list_dead = []
#累计治愈
list_heal = []
#现在确诊
list_nowConfirm = []
#总数据
list_sum = []
for li in res_list:
list1 = []
#国家名字
name = li['name']
list1.append(name)
list_name.append(name