feat(route): add 全民健康网 (#8507)

This commit is contained in:
Ethan Shen 2021-11-27 16:57:20 +08:00 committed by GitHub
parent a33ae5a274
commit 8b82fd0f86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 87 additions and 0 deletions

View File

@ -2243,6 +2243,24 @@ column 为 third 时可选的 category:
</Route>
## 全民健康网
<Route author="nczitzk" example="/qm120/news" path="/qm120/news/:category?" :paramsDesc="['分类,见下表,默认为健康焦点']">
| 健康焦点 | 行业动态 | 医学前沿 | 法规动态 |
| -------- | -------- | -------- | -------- |
| jdxw | hydt | yxqy | fgdt |
| 食品安全 | 医疗事故 | 医药会展 | 医药信息 |
| -------- | -------- | -------- | -------- |
| spaq | ylsg | yyhz | yyxx |
| 新闻专题 | 行业新闻 |
| -------- | -------- |
| zhuanti | xyxw |
</Route>
## 全球化智库
### 分类

View File

@ -0,0 +1,3 @@
module.exports = {
'/news/:category?': ['nczitzk'],
};

50
lib/v2/qm120/news.js Normal file
View File

@ -0,0 +1,50 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const timezone = require('@/utils/timezone');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const category = ctx.params.category ?? 'jdxw';
const rootUrl = 'http://www.qm120.com';
const currentUrl = `${rootUrl}/news/${category}`;
const response = await got({
method: 'get',
url: currentUrl,
});
const $ = cheerio.load(response.data);
let items = $('.lb2boxls ul li a')
.toArray()
.map((item) => {
item = $(item);
return {
title: item.text(),
link: item.attr('href'),
};
});
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
});
const content = cheerio.load(detailResponse.data);
item.description = content('.neirong_body').html();
item.pubDate = timezone(parseDate(content('.neirong_head p span').eq(1).text()), +8);
return item;
})
)
);
ctx.state.data = {
title: `${$('.zt_liebiao_tit').text()} - 全民健康网`,
link: currentUrl,
item: items,
};
};

13
lib/v2/qm120/radar.js Normal file
View File

@ -0,0 +1,13 @@
module.exports = {
'qm120.com': {
_name: '全民健康网',
'.': [
{
title: '新闻',
docs: 'https://docs.rsshub.app/new-media.html#quan-min-jian-kang-wang-xin-wen',
source: ['/'],
target: '/qm120/news/:category?',
},
],
},
};

3
lib/v2/qm120/router.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/news/:category?', require('./news'));
};