feat(route): vom (#10624)

This commit is contained in:
Tony
2022-08-27 00:04:02 +08:00
committed by GitHub
parent 925fe9de6d
commit 3c6d288330
6 changed files with 93 additions and 0 deletions
+12
View File
@@ -554,6 +554,18 @@ Provide full article RSS for WSJ topics.
</RouteEn>
## Voice of Mongolia
### News
<RouteEn author="zphw" example="/vom/featured" path="/vom/featured/:lang?" :paramsDesc="['Language, see the table below, `mn` by default']">
| English | 日本語 | Монгол | Русский | 简体中文 |
| ------- | --- | ------ | ------- | ---- |
| en | ja | mn | ru | zh |
</RouteEn>
## Yahoo
### News
+12
View File
@@ -1414,6 +1414,18 @@ category 对应的关键词有
<Route author="LyleLee" example="/reuters/investigates" path="/reuters/investigates" />
## 蒙古之声
### 新闻
<Route author="zphw" example="/vom/featured" path="/vom/featured/:lang?" :paramsDesc="['语言,见下表,默认 `mn`']">
| English | 日本語 | Монгол | Русский | 简体中文 |
| ------- | --- | ------ | ------- | ---- |
| en | ja | mn | ru | zh |
</Route>
## 明报
### 即时新闻
+50
View File
@@ -0,0 +1,50 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const baseUrl = 'http://www.vom.mn';
module.exports = async (ctx) => {
const { lang = 'mn' } = ctx.params;
const { data: response } = await got(`${baseUrl}/${lang}`);
const $ = cheerio.load(response);
const items = [
...new Set(
$('#bigNewsSlide .item, #news_3 .item')
.toArray()
.map((item) => {
item = $(item);
return {
link: item.find('a').eq(0).attr('href'),
};
})
),
];
await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = cheerio.load(response);
item.title = $('h2').text();
item.author = $('.uk-border-circle').next().text();
item.pubDate = parseDate($('.vom-news-show-meta .right').prev().text());
item.category = $('.vom-news-show-meta .uk-button-text').text();
$('.uk-article-title, .uk-text-meta, article .uk-grid-small').remove();
item.description = $('article').html();
return item;
})
)
);
ctx.state.data = {
title: $('meta[name=description]').attr('content'),
image: 'http://www.vom.mn/dist/images/vom-logo.png',
item: items,
};
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = {
'/featured/:lang?': ['TonyRL'],
};
+13
View File
@@ -0,0 +1,13 @@
module.exports = {
'vom.mn': {
_name: '蒙古之声',
'.': [
{
title: '新闻',
docs: 'https://docs.rsshub.app/traditional-media.html#meng-gu-zhi-sheng',
source: ['/:lang', '/'],
target: '/vom/featured/:lang',
},
],
},
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/featured/:lang?', require('./featured.js'));
};