肺炎疫情实时动态播报数据抓取代码小示例

答疑·限时优惠

如果,你想让我看见你的疑问并且百分之百的回答。可以加入我的知识星球。
AI悦创·进化岛
AI悦创·进化岛

你好,我是悦创。

网易疫情数据抓取,简单代码展示:

# -*- coding: utf-8 -*-
# @Author: clela
# @Date:   2020-03-31 14:13:35
# @Last Modified by:   clela
# @Last Modified time: 2020-04-01 23:45:58
import requests, json

url = 'https://c.m.163.com/ug/api/wuhan/app/data/list-total?t=317150961437'

headers = {
    'origin': 'https://wp.m.163.com',
    'referer': 'https://wp.m.163.com/163/page/news/virus_report/index.html',
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36',
}
html = requests.get(url, headers = headers).text
# print(html.text)
json_text = json.loads(html)["data"]['chinaTotal']['total']
# print(json_text)
for key, value in json_text.items():
    print(key, value)
AI悦创·创造不同!
AI悦创 » 肺炎疫情实时动态播报数据抓取代码小示例

Leave a Reply