feat: add coronavirus dxy data
This commit is contained in:
parent
090a8c5ec3
commit
5be2a5c156
|
|
@ -394,10 +394,18 @@ type 为 all 时,category 参数不支持 cost 和 free
|
|||
|
||||
<Route author="DIYgod" example="/coronavirus/caixin" path="/coronavirus/caixin"/>
|
||||
|
||||
### 丁香园 - 全国新型肺炎疫情实时动态
|
||||
### 丁香园 - 全国新型肺炎疫情实时播报
|
||||
|
||||
<Route author="DIYgod" example="/coronavirus/dxy" path="/coronavirus/dxy"/>
|
||||
|
||||
### 丁香园 - 全国新型肺炎疫情数据统计(全国)
|
||||
|
||||
<Route author="DIYgod" example="/coronavirus/dxy/data" path="/coronavirus/dxy/data"/>
|
||||
|
||||
### 丁香园 - 全国新型肺炎疫情数据统计(各省份)
|
||||
|
||||
<Route author="DIYgod" example="/coronavirus/dxy/data/湖北" path="/coronavirus/dxy/data/:province"/>
|
||||
|
||||
### South China Morning Post - China coronavirus outbreak
|
||||
|
||||
<Route author="DIYgod" example="/coronavirus/scmp" path="/coronavirus/scmp"/>
|
||||
|
|
|
|||
|
|
@ -2155,6 +2155,8 @@ router.get('/weixin/miniprogram/release', require('./routes/weixinMiniprogram/re
|
|||
|
||||
// 武汉肺炎疫情动态
|
||||
router.get('/coronavirus/caixin', require('./routes/coronavirus/caixin'));
|
||||
router.get('/coronavirus/dxy/data/:province', require('./routes/coronavirus/dxy-data-province'));
|
||||
router.get('/coronavirus/dxy/data', require('./routes/coronavirus/dxy-data-country'));
|
||||
router.get('/coronavirus/dxy', require('./routes/coronavirus/dxy'));
|
||||
router.get('/coronavirus/scmp', require('./routes/coronavirus/scmp'));
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
const got = require('@/utils/got');
|
||||
const jsdom = require('jsdom');
|
||||
const { JSDOM } = jsdom;
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: 'https://3g.dxy.cn/newh5/view/pneumonia',
|
||||
});
|
||||
|
||||
const dom = new JSDOM(response.data, {
|
||||
runScripts: 'dangerously',
|
||||
});
|
||||
|
||||
const data = dom.window.getStatisticsService;
|
||||
|
||||
ctx.state.data = {
|
||||
title: '全国新型肺炎疫情数据统计(全国)-丁香园',
|
||||
link: 'https://3g.dxy.cn/newh5/view/pneumonia',
|
||||
item: [
|
||||
{
|
||||
title: data.countRemark,
|
||||
pubDate: new Date(data.modifyTime).toUTCString(),
|
||||
},
|
||||
],
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
const got = require('@/utils/got');
|
||||
const jsdom = require('jsdom');
|
||||
const { JSDOM } = jsdom;
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const province = ctx.params.province;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: 'https://3g.dxy.cn/newh5/view/pneumonia',
|
||||
});
|
||||
|
||||
const dom = new JSDOM(response.data, {
|
||||
runScripts: 'dangerously',
|
||||
});
|
||||
|
||||
const data = dom.window.getAreaStat.find((item) => item.provinceShortName === province);
|
||||
let descriptionCity = '';
|
||||
if (data.cities) {
|
||||
for (let i = 0; i < data.cities.length; i++) {
|
||||
descriptionCity += `<br><br>${data.cities[i].cityName}:确诊 ${data.cities[i].confirmedCount} 例,死亡 ${data.cities[i].deadCount} 例,治愈 ${data.cities[i].curedCount} 例`;
|
||||
}
|
||||
}
|
||||
|
||||
const title = `确诊 ${data.confirmedCount} 例,死亡 ${data.deadCount} 例,治愈 ${data.curedCount} 例`;
|
||||
|
||||
ctx.state.data = {
|
||||
title: `全国新型肺炎疫情数据统计(${province})-丁香园`,
|
||||
link: 'https://3g.dxy.cn/newh5/view/pneumonia',
|
||||
item: data && [
|
||||
{
|
||||
title: title,
|
||||
description: `${title}${descriptionCity}`,
|
||||
pubDate: new Date(dom.window.getStatisticsService.modifyTime).toUTCString(),
|
||||
},
|
||||
],
|
||||
};
|
||||
};
|
||||
|
|
@ -15,7 +15,7 @@ module.exports = async (ctx) => {
|
|||
const data = dom.window.getTimelineService;
|
||||
|
||||
ctx.state.data = {
|
||||
title: '全国新型肺炎疫情实时动态-丁香园',
|
||||
title: '全国新型肺炎疫情实时播报-丁香园',
|
||||
link: 'https://3g.dxy.cn/newh5/view/pneumonia',
|
||||
item: data.map((item) => ({
|
||||
title: item.title,
|
||||
|
|
|
|||
Loading…
Reference in New Issue