zoukankan      html  css  js  c++  java
  • 移动端疫情展示

    要求开发一款移动端的全世界疫情实时查询系统。

    要求将前两周的项目合并为一个完整的项目。

    采用统一的数据库。(建议MySQL数据库)

    实现从数据采集、数据存储、数据查询(WEB端和移动端)一体全世界实时疫情查询系统。

    以本机数据库为服务器端,web端和移动端连接远程数据库实现数据共享,要求数据库表格式统一化。

    查询显示当前最新时间的数据,可以查询任一时间任一地点的数据。该系统要求在服务器端发布,可以通过IP地址访问

    项目代码

     

    import pymysqlimport requestsimport json
    url_foreign = "https://api.inews.qq.com/newsqa/v1/automation/foreign/country/ranklist"
    url_inside = "https://view.inews.qq.com/g2/getOnsInfo?name=disease_h5"
    header = {"user-agent": "Mozilla/5.0 (Linux; Android 8.0.0; Pixel 2 XL Build/OPD1.170816.004) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.116 Mobile Safari/537.36"}
    response_foreign = requests.get(url_foreign, headers=header)
    response_inside = requests.get(url_inside,headers=header)
    data_foreign = json.loads(response_foreign.content.decode())
    data_str_foreign = data_foreign['data']
    data_inside = json.loads(response_inside.content.decode())
    data_str_inside = data_inside['data']
    data_json_inside = json.loads(data_str_inside)
    db = pymysql.connect(host='39.97.109.245', port=3306, user='root', password='0608', db='yiqing', charset='utf8')
    cursor = db.cursor()
    confirmed_total = 0
    suspected_total = 0
    dead_total = 0
    healed_total = 0
    # 更新时间
    lastUpdateTime = data_json_inside['lastUpdateTime']
    # 取出外国的数据for foreignData in data_str_foreign:
        countryName = foreignData['name']
        confirmed = foreignData['confirm']
        confirmed_total += confirmed
        suspected = foreignData['suspect']
        suspected_total += suspected
        dead = foreignData['dead']
        dead_total += dead
        healed = foreignData['heal']
        healed_total += healed
        sql = "insert into worlddata(id,countryname,confirmed,suspected,dead,healed,lastupdateTime) values({},'{}','{}','{}','{}', '{}','{}')".format(0, countryName, confirmed, suspected, dead, healed, lastUpdateTime)
        cursor.execute(sql)
        db.commit()
    ChinaName = data_json_inside['areaTree'][0]['name']
    china_confirmed = data_json_inside['areaTree'][0]['total']['confirm']
    confirmed_total += china_confirmed
    china_suspected = data_json_inside['areaTree'][0]['total']['suspect']
    suspected_total += china_suspected
    china_healed = data_json_inside['areaTree'][0]['total']['heal']
    healed_total += china_healed
    china_dead = data_json_inside['areaTree'][0]['total']['dead']
    dead_total += dead_total
    # 将中国数据上传到数据库
    sql_china = "insert into worlddata(id,countryname,confirmed,suspected,dead,healed,lastupdateTime) values({},'{}','{}','{}','{}', '{}','{}')".format(
        0, ChinaName, china_confirmed, china_suspected, china_dead, china_dead, lastUpdateTime)
    cursor.execute(sql_china)
    db.commit()
    # 将汇总数据上传到数据库
    sql_total = "insert into worlddata(id,countryname,confirmed,suspected,dead,healed,lastupdateTime) values({},'{}','{}','{}','{}', '{}','{}')".format(0, 0, confirmed_total, suspected_total, dead_total, healed_total, lastUpdateTime)
    cursor.execute(sql_total)
    db.commit()

     

     

     

  • 相关阅读:
    学习Javascript闭包(Closure)
    JS的this原理
    页面锚点的设置
    JS异常捕获和抛出
    C++ 指针初始化要注意的地方
    Jupyter Notebook里面使用Matplotlib画图 图表中文乱码问题
    Matplotlib 基本图表的绘制
    Matplotlib 子图的创建
    Matplotlib 图表的样式参数
    Matplotlib 图表的基本参数设置
  • 原文地址:https://www.cnblogs.com/ICDTAD/p/13110830.html
Copyright © 2011-2022 走看看