• 移动端疫情展示


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

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

    采用统一的数据库。(建议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()

     

     

     

  • 相关阅读:
    学习总结之三(SQL SERVER游标CURSOR的使用)
    根据经纬度坐标计算两点间几何距离 椰子树下 CSDN博客
    多个CSS风格共用同一(背景)图片_那一片天_百度空间
    JAVA md5把我气到疯的代码,天哪,神呀,我的C# 啊。
    SQL中的系统变量一览
    在Windows下安装Redmine
    Fragment中的方法findFragmentById(int id)的返回值探讨
    AndroidVideoCache 框架源码分析
    从零开始编译属于你的FFmpeg
    Glide填坑指南
  • 原文地址:https://www.cnblogs.com/ICDTAD/p/13110830.html
Copyright © 2020-2023  润新知