mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-08 14:07:54 +08:00
feat: add route for nikkei (#3785)
This commit is contained in:
@@ -978,4 +978,15 @@
|
||||
},
|
||||
],
|
||||
},
|
||||
'nikkei.com': {
|
||||
_name: '日本経済新聞',
|
||||
www: [
|
||||
{
|
||||
title: 'ホームページ',
|
||||
docs: 'https://docs.rsshub.app/traditional-media.html#ri-ben-jing-ji-xin-wen',
|
||||
source: '/',
|
||||
target: '/nikkei/index',
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
@@ -320,6 +320,15 @@ category 对应的关键词有
|
||||
|
||||
<Route author="LogicJake" example="/people/xjpjh" path="/people/xjpjh/:keyword?/:year?" :paramsDesc="['关键词,默认不填','年份,默认all']"/>
|
||||
|
||||
## 日本経済新聞
|
||||
|
||||
### ホームページ
|
||||
|
||||
<Route author="zjysdhr" example="/nikkei/index" path="/nikkei/index" radar="1">
|
||||
|
||||
日文版首页
|
||||
|
||||
</Route>
|
||||
## 卫报 The Guardian
|
||||
|
||||
通过提取文章全文,以提供比官方源更佳的阅读体验。
|
||||
|
||||
@@ -2160,4 +2160,7 @@ router.get('/coronavirus/dxy', require('./routes/coronavirus/dxy'));
|
||||
router.get('/coronavirus/scmp', require('./routes/coronavirus/scmp'));
|
||||
router.get('/coronavirus/nhc', require('./routes/coronavirus/nhc'));
|
||||
|
||||
// 日本経済新聞
|
||||
router.get('/nikkei/index', require('./routes/nikkei/index'));
|
||||
|
||||
module.exports = router;
|
||||
|
||||
34
lib/routes/nikkei/index.js
Normal file
34
lib/routes/nikkei/index.js
Normal file
@@ -0,0 +1,34 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const url = 'https://www.nikkei.com';
|
||||
const response = await got({ method: 'get', url });
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('div[data-rn-track-category]')
|
||||
.map((_, e) => {
|
||||
const element = $(e);
|
||||
const title = element.data('rn-track-value').title;
|
||||
const link = url + element.find('a').attr('href');
|
||||
|
||||
const src = element.find('img').attr('src');
|
||||
const dataSrc = element.find('img').attr('data-src');
|
||||
|
||||
const imgSrc = dataSrc ? dataSrc : src;
|
||||
const desc = `<img src="${imgSrc}" />` + element.find('div .k-card__excerpt');
|
||||
|
||||
return {
|
||||
title: title,
|
||||
description: desc,
|
||||
link: link,
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
ctx.state.data = {
|
||||
title: '日本経済新聞',
|
||||
link: url,
|
||||
item: list,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user