feat(route): add 全民健康网 (#8507)
This commit is contained in:
parent
a33ae5a274
commit
8b82fd0f86
|
|
@ -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>
|
||||
|
||||
## 全球化智库
|
||||
|
||||
### 分类
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/news/:category?': ['nczitzk'],
|
||||
};
|
||||
|
|
@ -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,
|
||||
};
|
||||
};
|
||||
|
|
@ -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?',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/news/:category?', require('./news'));
|
||||
};
|
||||
Loading…
Reference in New Issue