mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-14 17:19:37 +08:00
feat(route): add World Health Organization Speeches (#8048)
Co-authored-by: DIYgod <diy.d.god@gmail.com>
This commit is contained in:
@@ -577,3 +577,15 @@ Language
|
||||
### Newsroom
|
||||
|
||||
<RouteEn author="LogicJake" example="/who/news-room/feature-stories" path="/who/news-room/:type" :paramsDesc="['类别,可在 URL 中找到']"/>
|
||||
|
||||
### Speeches
|
||||
|
||||
<RouteEn author="nczitzk" example="/who/speeches" path="/who/speeches/:language?" :paramsDesc="['Language, see below, English by default']">
|
||||
|
||||
Language
|
||||
|
||||
| English | العربية | 中文 | Français | Русский | Español | Português |
|
||||
| ------- | ------- | ---- | -------- | ------- | ------- | --------- |
|
||||
| en | ar | zh | fr | ru | es | pt |
|
||||
|
||||
</Route>
|
||||
@@ -2310,6 +2310,18 @@ column 为 third 时可选的 category:
|
||||
|
||||
<Route author="LogicJake" example="/who/news-room/feature-stories" path="/who/news-room/:type" :paramsDesc="['类别,可在 URL 中找到']"/>
|
||||
|
||||
### 总干事的讲话
|
||||
|
||||
<Route author="nczitzk" example="/who/speeches" path="/who/speeches/:language?" :paramsDesc="['语言,见下表,默认为英语']">
|
||||
|
||||
语言
|
||||
|
||||
| English | العربية | 中文 | Français | Русский | Español | Português |
|
||||
| ------- | ------- | ---- | -------- | ------- | ------- | --------- |
|
||||
| en | ar | zh | fr | ru | es | pt |
|
||||
|
||||
</Route>
|
||||
|
||||
## 数英网
|
||||
|
||||
### 数英网最新文章
|
||||
|
||||
@@ -1692,6 +1692,7 @@ router.get('/nintendo/system-update', lazyloadRouteHandler('./routes/nintendo/sy
|
||||
|
||||
// 世界卫生组织
|
||||
router.get('/who/news-room/:type', lazyloadRouteHandler('./routes/who/news-room'));
|
||||
router.get('/who/speeches/:language?', require('./routes/who/speeches'));
|
||||
router.get('/who/news/:language?', require('./routes/who/news'));
|
||||
|
||||
// 福利资源-met.red
|
||||
|
||||
45
lib/routes/who/speeches.js
Normal file
45
lib/routes/who/speeches.js
Normal file
@@ -0,0 +1,45 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const language = ctx.params.language || 'en';
|
||||
|
||||
const rootUrl = 'https://www.who.int';
|
||||
const currentUrl = `${rootUrl}/${language === 'en' ? '' : `${language}/`}director-general/speeches`;
|
||||
const apiUrl = `${rootUrl}/api/hubs/speeches?sf_culture=${language}&$orderby=PublicationDateAndTime%20desc&$select=Title,PublicationDateAndTime,ItemDefaultUrl`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: apiUrl,
|
||||
});
|
||||
|
||||
const list = response.data.value.map((item) => ({
|
||||
title: item.Title,
|
||||
link: `${currentUrl}/detail/${item.ItemDefaultUrl}`,
|
||||
pubDate: parseDate(item.PublicationDateAndTime),
|
||||
}));
|
||||
|
||||
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);
|
||||
|
||||
item.description = content('.sf-detail-body-wrapper').html();
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: 'Speeches - WHO',
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user