mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-10-29 18:06:31 +08:00
feat(route): taiwannews (#10178)
This commit is contained in:
@@ -8,7 +8,7 @@ pageClass: routes
|
||||
|
||||
### Immigration and Citizenship - News
|
||||
|
||||
<RouteEn author="liu233w" example="/gov/immiau/news" path="/gov/immiau/news">
|
||||
<RouteEn author="liu233w" example="/gov/immiau/news" path="/gov/immiau/news"/>
|
||||
|
||||
## Central Intelligence Agency
|
||||
|
||||
|
||||
@@ -462,6 +462,12 @@ Language
|
||||
|
||||
</RouteEn>
|
||||
|
||||
## Taiwan News
|
||||
|
||||
### Hot News
|
||||
|
||||
<RouteEn author="TonyRL" example="/taiwannews/hot" path="/taiwannews/hot/:lang?" :paramsDesc="['Language, `en` or `zh`, `en` by default']" radar="1" rssbud="1"/>
|
||||
|
||||
## The Economist
|
||||
|
||||
### Category
|
||||
@@ -589,9 +595,3 @@ Free articles only.
|
||||
| news | national | politics | economy | sports | world | science | election | culture | igoshougi | life | local | editorial | koushitsu |
|
||||
|
||||
</RouteEn>
|
||||
|
||||
## 公視新聞網
|
||||
|
||||
### Daily News
|
||||
|
||||
<RouteEn author="nczitzk" example="/pts/dailynews" path="/pts/dailynews"/>
|
||||
|
||||
@@ -1552,6 +1552,12 @@ category 对应的关键词有
|
||||
|
||||
</Route>
|
||||
|
||||
## 台灣英文新聞
|
||||
|
||||
### 最新熱門消息
|
||||
|
||||
<Route author="TonyRL" example="/taiwannews/hot" path="/taiwannews/hot/:lang?" :paramsDesc="['語言,`en` 或 `zh`,默認 `en`']" radar="1" rssbud="1"/>
|
||||
|
||||
## 卫报 The Guardian
|
||||
|
||||
通过提取文章全文,以提供比官方源更佳的阅读体验。
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const baseUrl = 'https://www.taiwannews.com.tw';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { lang = 'en' } = ctx.params;
|
||||
const url = `${baseUrl}/${lang}/index`;
|
||||
const response = await got(url);
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('.mod_group-columns .container-fluid .row')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
const a = item.find('a');
|
||||
return {
|
||||
title: a.attr('title'),
|
||||
link: new URL(a.attr('href'), baseUrl).href,
|
||||
pubDate: timezone(parseDate(item.find('.entry-date span').eq(1).text(), 'YYYY/MM/DD HH:mm'), +8),
|
||||
};
|
||||
});
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const response = await got(item.link);
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
item.author = $('.article-author').text();
|
||||
item.category = $('.tagcloud a')
|
||||
.toArray()
|
||||
.map((a) => $(a).attr('title'));
|
||||
|
||||
$('.article-head-wrapper, div[id^=div-gpt-ad-], div[class^=hidden-], footer').remove();
|
||||
$('.container-fluid').eq(2).remove();
|
||||
|
||||
item.description = $('.mod_single-column').html();
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${$('.categories').eq(0).text()} - ${$('head title').text()}`,
|
||||
description: $('meta[name="description"]').attr('content'),
|
||||
link: url,
|
||||
item: items,
|
||||
language: lang,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/hot/:lang?': ['TonyRL'],
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'taiwannews.com.tw': {
|
||||
_name: '台灣英文新聞',
|
||||
'.': [
|
||||
{
|
||||
title: '最新熱門消息',
|
||||
docs: 'httsp://docs.rsshub.app/traditional-media.html#tai-wan-ying-wen-xin-wen',
|
||||
source: '/:lang/index',
|
||||
target: '/taiwannews/hot/:lang',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = (router) => {
|
||||
router.get('/hot/:lang?', require('./hot'));
|
||||
};
|
||||
Reference in New Issue
Block a user