fix(route): 靠谱新闻 (#7879)
This commit is contained in:
parent
e949195db1
commit
0889aeeff7
|
|
@ -740,7 +740,7 @@ category 对应的关键词有
|
|||
|
||||
### 新闻聚合
|
||||
|
||||
<Route author="wushijishan" example="/kaopunews/all" path="/kaopunews/all"/>
|
||||
<Route author="wushijishan nczitzk" example="/kaopunews/:language?" path="/kaopunews" :paramsDesc="['语言,可选 zh-hans 即简体中文,或 zh-hant 即繁体中文']"/>
|
||||
|
||||
## 连线 Wired
|
||||
|
||||
|
|
|
|||
|
|
@ -3157,7 +3157,7 @@ router.get('/erbingapp/news', require('./routes/erbingapp/news'));
|
|||
router.get('/dsb/area/:area', require('./routes/dsb/area'));
|
||||
|
||||
// 靠谱新闻
|
||||
router.get('/kaopunews/all', require('./routes/kaopunews/all'));
|
||||
router.get('/kaopunews/:language?', require('./routes/kaopunews'));
|
||||
|
||||
// Reuters
|
||||
router.get('/reuters/theWire', require('./routes/reuters/theWire'));
|
||||
|
|
|
|||
|
|
@ -1,30 +0,0 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: 'https://kaopu.news/',
|
||||
});
|
||||
|
||||
const data = response.data;
|
||||
|
||||
const $ = cheerio.load(data);
|
||||
const list = $('a[target="_blank"]');
|
||||
ctx.state.data = {
|
||||
title: '靠谱新闻',
|
||||
link: 'https://kaopu.news/',
|
||||
item:
|
||||
list &&
|
||||
list
|
||||
.map((index, item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
title: `${item.find('h3').text()}(${item.attr('class').substring(8)})`,
|
||||
description: item.find('h3').next().next().text(),
|
||||
link: item.attr('href'),
|
||||
};
|
||||
})
|
||||
.get(),
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
const got = require('@/utils/got');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const language = ctx.params.language || '';
|
||||
|
||||
const rootUrl = 'https://kaopu.news';
|
||||
const currentUrl = `${rootUrl}/${language === 'zh-hant' ? 'zh-hant' : 'index'}.html`;
|
||||
const apiUrl = `https://kaopucdn.azureedge.net/jsondata/news_han${language === 'zh-hant' ? 't' : 's'}_0.json`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: apiUrl,
|
||||
});
|
||||
|
||||
const items = response.data.map((item) => ({
|
||||
link: item.link,
|
||||
title: item.title,
|
||||
author: item.publisher,
|
||||
pubDate: new Date(item.first_seen * 1000),
|
||||
description: `<p>${item.story_summary}</p>`,
|
||||
}));
|
||||
|
||||
ctx.state.data = {
|
||||
title: language === 'zh-hant' ? '靠譜新聞' : '靠谱新闻',
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue