当前位置: 首页 > news >正文

网站大连顺义广州网站建设

网站大连,顺义广州网站建设,网站月流量5g,医院网站asp1.项目准备 在项目中使用到了jsoup和fastjson jsoup用于创建一个连接(绘画) 用于获取和解析HTML页面 而fastjson对数据进行一个格式化 在pom.xml导入坐标 dependenciesdependencygroupIdcom.alibaba/groupIdartifactIdfastjson/a…1.项目准备 在项目中使用到了jsoup和fastjson jsoup用于创建一个连接(绘画) 用于获取和解析HTML页面 而fastjson对数据进行一个格式化 在pom.xml导入坐标 dependenciesdependencygroupIdcom.alibaba/groupIdartifactIdfastjson/artifactIdversion2.0.15.graal/version/dependencydependencygroupIdorg.jsoup/groupIdartifactIdjsoup/artifactIdversion1.15.3/version/dependency/dependencies 在爬取数据之前需要先找到对应的数据接口https://api.inews.qq.com/newsqa/v1/query/inner/publish/modules/list?moduleslocalCityNCOVDataList,diseaseh5Shelf 返回的是json数据 这边建议使用json格式化工具观看方便后面提取数据 JSON在线解析,JSON格式化,JSON解析,JSON 校验SO JSON 2.实现 package com.czxy;import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import org.jsoup.Jsoup;import java.io.IOException; import java.util.Date; import java.util.HashMap; import java.util.Map;/*** author 陶然同学* version 1.0* date 2022/10/15 10:41*/ public class QQData {public static void main(String[] args) throws IOException {getAllData();}public static MapString,Object getAllData() throws IOException {//1 发送请求 连接 获得疫情数据String resultBody Jsoup.connect(https://api.inews.qq.com/newsqa/v1/query/inner/publish/modules/list?moduleslocalCityNCOVDataList,diseaseh5Shelf).ignoreContentType(true).execute().body();//2 转换成Object类型JSONObject jsonObject JSON.parseObject(resultBody);//3 获取data部分JSONObject data jsonObject.getJSONObject(data);//4 获取高风险地区数据JSONArray localCityNCOVDataList data.getJSONArray(localCityNCOVDataList);MapString,Object highCitysMap new HashMap();System.out.println(高风险疫情地区数据);for (int i 0; i localCityNCOVDataList.size(); i) {JSONObject highCity localCityNCOVDataList.getJSONObject(i);//高风险地区疫情数据 // System.out.println(highCity);//数据部分String city highCity.getString(city);String province highCity.getString(province);//本土确诊int local_confirm_add highCity.getIntValue(local_confirm_add);//新增无症状int local_wzz_add highCity.getIntValue(local_wzz_add);//高风险地区int highRiskAreaNum highCity.getIntValue(highRiskAreaNum);//中风险地区int mediumRiskAreaNum highCity.getIntValue(mediumRiskAreaNum);MapString,Object highCityMap new HashMap();highCityMap.put(city,city);highCityMap.put(province,province);highCityMap.put(local_confirm_add,local_confirm_add);highCityMap.put(highRiskAreaNum,highRiskAreaNum);highCityMap.put(mediumRiskAreaNum,mediumRiskAreaNum);highCityMap.put(name,highCityMap);}JSONObject diseaseh5Shelf data.getJSONObject(diseaseh5Shelf);//获取国内34个省市的疫情数据JSONArray areaTree diseaseh5Shelf.getJSONArray(areaTree);JSONObject allProvinces areaTree.getJSONObject(0);JSONArray provinces allProvinces.getJSONArray(children);MapString,Object provincesMap new HashMap();System.out.println(各省份疫情数据);for (int i 0; i provinces.size(); i) {JSONObject province provinces.getJSONObject(i);//获取省份数据MapString, Object provinceMap getCityValues(province);//打印省份数据System.out.println((String) provinceMap.get(name) province \n\t城市数据);provincesMap.put((String)provinceMap.get(name),provinceMap);//获得省下面的市JSONArray citys province.getJSONArray(children);MapString,Object citysMap new HashMap();for (int j 0; j citys.size(); j) {JSONObject city citys.getJSONObject(j);//获取城市数据MapString, Object cityMap getCityValues(city);//打印城市数据System.out.println(\t (String)cityMap.get(name) city);citysMap.put((String)cityMap.get(name),cityMap);}//获取国内全国疫情数据MapString,Object chinaMap new HashMap();JSONObject chinaTotal diseaseh5Shelf.getJSONObject(chinaTotal);//已治愈人数int heal chinaTotal.getIntValue(heal);//累计死亡int dead chinaTotal.getIntValue(dead);//新增无症状int localWzzAdd chinaTotal.getIntValue(localWzzAdd);//累计确诊 所有病例int confirm chinaTotal.getIntValue(confirm);//新增病例int confirmAdd chinaTotal.getIntValue(confirmAdd);//当前病例int nowConfirm chinaTotal.getIntValue(nowConfirm);//本土病例int localConfirm chinaTotal.getIntValue(localConfirm);//新增死亡int deadAdd chinaTotal.getIntValue(deadAdd);//本土新增病例int localConfirmAdd chinaTotal.getIntValue(localConfirmAdd);//中风险地区int mediumRiskAreaNum chinaTotal.getIntValue(mediumRiskAreaNum);//高风险地区int highRiskAreaNum chinaTotal.getIntValue(highRiskAreaNum);chinaMap.put(head,heal);chinaMap.put(dead,dead);chinaMap.put(localWzzAdd,localWzzAdd);chinaMap.put(confirm,confirm);chinaMap.put(confirmAdd,confirmAdd);chinaMap.put(nowConfirm,nowConfirm);chinaMap.put(deadAdd,deadAdd);chinaMap.put(localConfirmAdd,localConfirmAdd);chinaMap.put(mediumRiskAreaNum,mediumRiskAreaNum);chinaMap.put(highRiskAreaNum,highRiskAreaNum);//数据截止时间Date lastUpdateTime diseaseh5Shelf.getDate(lastUpdateTime);MapString,Object resultMap new HashMap();resultMap.put(provincesMap,provincesMap);resultMap.put(chinaMap,chinaMap);resultMap.put(highCitysMap,highCitysMap);resultMap.put(lastUpdateTime,lastUpdateTime);return resultMap;}return null;}/**** param province 省数据* return*/public static MapString,Object getCityValues(JSONObject province){//省名String name province.getString(name);//省的今天数据JSONObject today province.getJSONObject(today);//新增确证int todayConfirm today.getIntValue(confirm);//新增本土无症状int wzz_add today.getIntValue(wzz_add);//新增本土int local_confirm_add today.getIntValue(local_confirm_add);//省的历史数据JSONObject total province.getJSONObject(total);//累计确诊int confirm total.getIntValue(confirm);int nowConfirm total.getIntValue(nowConfirm);int wzz total.getIntValue(wzz);//中风险地区数量int mediumRiskAreaNum total.getIntValue(mediumRiskAreaNum);//高风险地区数量int highRiskAreaNum total.getIntValue(highRiskAreaNum);//累计死亡int heal total.getIntValue(heal);//累计确诊int dead total.getIntValue(confirm);MapString,Object provinceMap new HashMap();provinceMap.put(name,name);provinceMap.put(todayConfirm,todayConfirm);provinceMap.put(confirm,confirm);provinceMap.put(newConfirm,nowConfirm);provinceMap.put(wzz,wzz);provinceMap.put(mediumRiskAreaNum,mediumRiskAreaNum);provinceMap.put(highRiskAreaNum,highRiskAreaNum);provinceMap.put(heal,heal);provinceMap.put(dead,dead);return provinceMap;} }
http://www.hkea.cn/news/14465917/

相关文章:

  • h5网站开发培训哪里好上海最大的广告公司
  • 黄埔区网站建设数据展示网站模板
  • 淄川网站建设yx718怎样建免费个人网站
  • 全国网站建设有实力山西钢建公司简介
  • 怎样做淘宝网站简约商务ppt模板免费下载
  • 企业网站的设计与开发建设美食网站
  • 个人建网站运营.营销型网站推广
  • 做网站绘制蓝图的步骤开发企业网站要多少小时
  • 西安高校定制网站建设公司推荐it运维服务管理体系
  • 用ps做零食网站模板WordPress缩略图标签
  • 网站优化有哪些深圳歌剧院设计方案
  • 企业信息型网站有哪些人才招聘网最新招聘2022
  • jsp网站开发模式门户网站建设中存在的问题
  • 山东企业网站建设哪家好wordpress添加vip角色
  • 怎么修改网站后台权限企业网站不备案
  • 孝感做网站的公司wordpress禁用react
  • 网站建设职位呼和浩特做网站哪家公司好
  • 个人网站有什么缺点做学校网站素材图片大全
  • jsp购物网站开发 论文廊坊做网站的企业哪家好
  • 建设视频网站设计意义wordpress社区功能
  • 乐昌北京网站建设网站 免备案
  • 企业网站运维建站快车管理
  • 前端网站推荐美工培训班要多少学费
  • 旅游网站制作模板菏泽建设企业网站
  • 网站服务器租用合同wordpress页面定制
  • 食品经营许可网站增项怎么做网站描述作用
  • 本地网站有什么可以做前台登录 wordpress
  • 自己建网站的流程做俄罗斯网站
  • 网上做公益的网站有一个姑娘莱芜的莱芜的
  • 阿里云从哪里建设网站前端静态页面接单