feat(route): rodong (#11805)

This commit is contained in:
Tony
2023-02-08 22:40:09 +07:00
committed by GitHub
parent 1e83e7ddc1
commit 6cd2289d05
6 changed files with 88 additions and 0 deletions
+12
View File
@@ -433,6 +433,18 @@ More could be found in the URL of the category/topic page.
<RouteEn author="LyleLee" example="/reuters/investigates" path="/reuters/investigates" />
## Rodong Sinmun
### News
<RouteEn author="TonyRL" example="/rodong/news" path="/rodong/news/:language?" :paramsDesc="['Language, see below, `ko` by default']" radar="1">
| 조선어 | English | 中文 |
| ---- | ------ | --- |
| ko | en | cn |
</RouteEn>
## RTHK
### News
+12
View File
@@ -1346,6 +1346,18 @@ category 对应的关键词有
</Route>
## 劳动新闻
### 新闻
<Route author="TonyRL" example="/rodong/news" path="/rodong/news/:language?" :paramsDesc="['语言,见下表,默认 `ko`']" radar="1">
| 조선어 | English | 中文 |
| --- | ------- | -- |
| ko | en | cn |
</Route>
## 理论网
### 学习时报
+3
View File
@@ -0,0 +1,3 @@
module.exports = {
'/news/:language?': ['TonyRL'],
};
+45
View File
@@ -0,0 +1,45 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const host = 'http://www.rodong.rep.kp';
module.exports = async (ctx) => {
const { language = 'ko' } = ctx.params;
const link = `${host}/${language}/index.php?MkBAMkAxQA==`;
const { data: response } = await got(link);
const $ = cheerio.load(response);
const list = $('.date_news_list .row')
.toArray()
.map((item) => {
item = $(item);
return {
title: item.find('.media-body').text(),
link: `${host}/${language}/${item.find('.media-body a').attr('href')}`,
author: item.find('.col-sm-3').text(),
pubDate: parseDate(item.find('.news_date').text(), 'YYYY.M.D.'),
};
});
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = cheerio.load(response);
$('.news_Title, .NewsDetail, .News_Detail, #moveNews').remove();
item.description = $('.col-sm-8').html();
return item;
})
)
);
ctx.state.data = {
title: $('head title').text(),
description: $('head meta[name="description"]').attr('content'),
link,
item: items,
};
};
+13
View File
@@ -0,0 +1,13 @@
module.exports = {
'rodong.rep.kp': {
_name: '劳动新闻',
'.': [
{
title: '新闻',
docs: 'https://docs.rsshub.app/traditional-media.html#lao-dong-xin-wen',
source: ['/cn/index.php', '/en/index.php', '/ko/index.php', '/cn', '/en', '/ko'],
target: '/rodong/news',
},
],
},
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/news/:language?', require('./news'));
};