feat(route): add 梅斯医学MedSci (#8736)
This commit is contained in:
parent
48b5573d1c
commit
c95762af47
|
|
@ -2212,9 +2212,55 @@ column 为 third 时可选的 category:
|
|||
|
||||
## 梅斯医学 MedSci
|
||||
|
||||
### 推荐
|
||||
### 资讯
|
||||
|
||||
<Route author="nczitzk" example="/medsci/recommend" path="/medsci/recommend"/>
|
||||
<Route author="nczitzk" example="/medsci" path="/medsci/:sid?/:tid?" :paramsDesc="['科室,见下表,默认为推荐', '亚专业,可在对应科室页 URL 中找到,默认为该科室的全部']">
|
||||
|
||||
::: tip 提示
|
||||
|
||||
下表为科室对应的 sid,若想获得 tid,可以到对应科室页面 URL 中寻找 `t_id` 字段的值,下面是一个例子:
|
||||
|
||||
如 [肿瘤 - NSCLC](https://www.medsci.cn/department/details?s_id=5&t_id=277) 的 URL 为 <https://www.medsci.cn/department/details?s_id=5&t_id=277>,可以看到此时 `s_id` 对应 `sid` 的值为 5, `t_id` 对应 `tid` 的值为 277,所以可以得到路由 [`/medsci/5/277`](https://rsshub.app/medsci/5/277)
|
||||
|
||||
:::
|
||||
|
||||
| 心血管 | 内分泌 | 消化 | 呼吸 | 神经科 |
|
||||
| ------ | ------ | ---- | ---- | ------ |
|
||||
| 2 | 6 | 4 | 12 | 17 |
|
||||
|
||||
| 传染科 | 精神心理 | 肾内科 | 风湿免疫 | 血液科 |
|
||||
| ------ | -------- | ------ | -------- | ------ |
|
||||
| 9 | 13 | 14 | 15 | 21 |
|
||||
|
||||
| 老年医学 | 胃肠外科 | 血管外科 | 肝胆胰外 | 骨科 |
|
||||
| -------- | -------- | -------- | -------- | ---- |
|
||||
| 19 | 76 | 92 | 91 | 10 |
|
||||
|
||||
| 普通外科 | 胸心外科 | 神经外科 | 泌尿外科 | 烧伤科 |
|
||||
| -------- | -------- | -------- | -------- | ------ |
|
||||
| 23 | 24 | 25 | 26 | 27 |
|
||||
|
||||
| 整形科 | 麻醉疼痛 | 罕见病 | 康复医学 | 药械 |
|
||||
| ------ | -------- | ------ | -------- | ---- |
|
||||
| 28 | 29 | 304 | 95 | 11 |
|
||||
|
||||
| 儿科 | 耳鼻咽喉 | 口腔科 | 眼科 | 政策人文 |
|
||||
| ---- | -------- | ------ | ---- | -------- |
|
||||
| 18 | 30 | 31 | 32 | 33 |
|
||||
|
||||
| 营养全科 | 预防公卫 | 妇产科 | 中医科 | 急重症 |
|
||||
| -------- | -------- | ------ | ------ | ------ |
|
||||
| 34 | 35 | 36 | 37 | 38 |
|
||||
|
||||
| 皮肤性病 | 影像放射 | 转化医学 | 检验病理 | 护理 |
|
||||
| -------- | -------- | -------- | -------- | ---- |
|
||||
| 39 | 40 | 42 | 69 | 79 |
|
||||
|
||||
| 糖尿病 | 冠心病 | 肝病 | 乳腺癌 |
|
||||
| ------ | ------ | ---- | ------ |
|
||||
| 8 | 43 | 22 | 89 |
|
||||
|
||||
</Route>
|
||||
|
||||
## 美国半导体行业协会
|
||||
|
||||
|
|
|
|||
|
|
@ -1,51 +0,0 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const date = require('@/utils/date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const currentUrl = 'http://www.medsci.cn';
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const list = $('div.composs-panel-inner div.composs-blog-list div.item div.item-content h2 a.ms-link')
|
||||
.slice(0, 10)
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
title: item.text(),
|
||||
link: item.attr('href'),
|
||||
pubDate: date(item.parent().parent().find('span.item-meta-item').eq(0).text()),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
const publishedTime = detailResponse.data.match(/"publishedTime":"(.*?)","publishedTimeString"/);
|
||||
|
||||
const type = item.link.split('/')[3];
|
||||
|
||||
item.pubDate = publishedTime ? new Date(publishedTime[1]).toUTCString() : item.pubDate;
|
||||
item.description = type === 'article' ? content('div.article-content-box').html() : content('shortcode-content').html();
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '梅斯医学 - 推荐',
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate, parseRelativeDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
let sid = ctx.params.sid ?? '';
|
||||
const tid = ctx.params.tid ?? '';
|
||||
|
||||
sid = sid === 'recommend' ? '' : sid;
|
||||
|
||||
const rootUrl = 'https://www.medsci.cn';
|
||||
const currentUrl = `${rootUrl}${sid ? `/department/details?s_id=${sid}&module=article${tid ? `&t_id=${tid}` : ''}` : ''}`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
let items = $('#articleList')
|
||||
.find('.ms-link')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
|
||||
const pubDate = item.parent().parent().find('.item-meta-item').first().text();
|
||||
|
||||
return {
|
||||
title: item.text(),
|
||||
link: `${rootUrl}${item.attr('href').replace(/;jsessionid=[A-Z0-9]+/, '')}`,
|
||||
pubDate: pubDate.indexOf('-') > 0 ? parseDate(pubDate) : parseRelativeDate(pubDate),
|
||||
};
|
||||
});
|
||||
|
||||
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);
|
||||
|
||||
const pubDateMatches = detailResponse.data.match(/"publishedTime":"(.*)","publishedTimeString"/);
|
||||
|
||||
item.author = content('.name').text();
|
||||
item.description = content('#content').html();
|
||||
item.pubDate = pubDateMatches ? parseDate(pubDateMatches[1]) : item.pubDate;
|
||||
item.category =
|
||||
content('meta[name="keywords"]')
|
||||
.attr('content')
|
||||
?.split(/,|,/)
|
||||
.filter((c) => c !== '' && c !== 'undefined') ?? [];
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${sid ? $('.department-header-active').text() : '推荐'} -${tid ? ` ${$('.department-keywords-ul .active').text()} -` : ''} MedSci.cn`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/:sid?/:tid?': ['nczitzk'],
|
||||
};
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
module.exports = {
|
||||
'medsci.cn': {
|
||||
_name: '梅斯医学',
|
||||
'.': [
|
||||
{
|
||||
title: '资讯',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#mei-si-yi-xue-zi-xun',
|
||||
source: ['/department/details', '/'],
|
||||
target: (params) => `/medsci${params.s_id ? `/${params.s_id}${params.t_id ? `/${params.s_id}` : ''}` : ''}`,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/:sid?/:tid?', require('./index'));
|
||||
};
|
||||
Loading…
Reference in New Issue