feat(route): add 俄罗斯卫星通讯社 (#9272)

* feat(route): add 俄罗斯卫星通讯社

* fix: add radar
This commit is contained in:
Ethan Shen
2022-03-09 19:59:40 +11:00
committed by GitHub
parent 666d2bcc59
commit ce511b5b17
5 changed files with 90 additions and 0 deletions
+12
View File
@@ -766,6 +766,18 @@ Type 栏目:
<Route author="HenryQW" example="/dwnews/rank" path="/dwnews/rank"/>
## 俄罗斯卫星通讯社
### 分类
<Route author="nczitzk" example="/sputniknews" path="/sputniknews/:category?" :paramsDesc="['分类,见下表,默认为 news']">
| 新闻 | 中国 | 俄罗斯 | 国际 | 俄中关系 | 评论 |
| ---- | ----- | ------ | -------------- | ---------------------- | ------- |
| news | china | russia | category_guoji | russia_china_relations | opinion |
</Route>
## 公視新聞網
### 即時新聞
+59
View File
@@ -0,0 +1,59 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const category = ctx.params.category ?? 'news';
const rootUrl = 'https://sputniknews.cn';
const currentUrl = `${rootUrl}/services/${category}/more.html`;
const response = await got({
method: 'get',
url: currentUrl,
});
const $ = cheerio.load(response.data);
let items = $('.list__title')
.toArray()
.map((item) => {
item = $(item);
return {
title: item.text(),
link: `${rootUrl}${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.category = content('.tag__text')
.toArray()
.map((tag) => content(tag).text());
content('.article__meta, .article__title, .article__info, .article__quote-bg, .article__footer, .m-buy, .photoview__ext-link').remove();
content('div[data-type="article"]').remove();
item.description = content('.article').html();
item.pubDate = parseDate(content('div[itemprop="datePublished"]').attr('data-unixtime'));
return item;
})
)
);
ctx.state.data = {
title: `${category} - 俄罗斯卫星通讯社`,
link: `${rootUrl}/${category}`,
item: items,
};
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = {
'/:category?': ['nczitzk'],
};
+13
View File
@@ -0,0 +1,13 @@
module.exports = {
'sputniknews.cn': {
_name: '俄罗斯卫星通讯社',
'.': [
{
title: '分类',
docs: 'https://docs.rsshub.app/traditional-media.html#e-luo-si-wei-xing-tong-xun-she-fen-lei',
source: ['/:category', '/'],
target: '/sputniknews/:category',
},
],
},
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/:category?', require('./index'));
};