mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-07 21:47:57 +08:00
feat: 朝日新聞中文网简体中文版 (#2146)
* 修正了朝日新闻中文网繁体中文版的文档 * 增加了朝日新聞中文网简体中文版 * 提交route.js
This commit is contained in:
@@ -282,11 +282,39 @@ category 对应的关键词有
|
|||||||
|
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
## 朝日新聞中文網
|
## 朝日新聞中文网(简体中文版)
|
||||||
|
|
||||||
### 新闻分类
|
### 新闻分类
|
||||||
|
|
||||||
<Route author="qiwihui" example="/sina/society" path="/sina/discovery/:category/:subCate?" :paramsDesc="['版块', '子板块']">
|
<Route author="zhouchang29" example="/asahichinese-j/society" path="/asahichinese-j/:category/:subCate?" :paramsDesc="['版块', '子版块']">
|
||||||
|
|
||||||
|
版块:
|
||||||
|
|
||||||
|
| society | politics_economy | cool_japan | travel | sports | business | technology | world | opinion |
|
||||||
|
| -------- | ---------------- | ---------- | ---------- | ---------- | ---------- | ---------- | ---------- | ---------- |
|
||||||
|
| 日本社会 | 政治・经济 | 文娱・生活 | 旅游・活动 | 体育・奥运 | 商务・商品 | IT・科技 | 国际・东亚 | 观点・专栏 |
|
||||||
|
|
||||||
|
版块 `cool_japan` 和 `travel` 包含子版块:
|
||||||
|
|
||||||
|
`cool_japan`:
|
||||||
|
|
||||||
|
| entertainment | anime | life | style_culture |
|
||||||
|
| ------------- | ----- | ---------- | ------------- |
|
||||||
|
| 艺能 | 动漫 | 生活・美食 | 时尚・文化 |
|
||||||
|
|
||||||
|
`travel`:
|
||||||
|
|
||||||
|
| news | scenery | topic | move |
|
||||||
|
| ---- | ------- | ----- | ---- |
|
||||||
|
| 资讯 | 风景 | 体验 | 交通 |
|
||||||
|
|
||||||
|
</Route>
|
||||||
|
|
||||||
|
## 朝日新聞中文網(繁體中文版)
|
||||||
|
|
||||||
|
### 新聞分類
|
||||||
|
|
||||||
|
<Route author="qiwihui" example="/asahichinese-f/society" path="/asahichinese-f/:category/:subCate?" :paramsDesc="['版块', '子版块']">
|
||||||
|
|
||||||
版块:
|
版块:
|
||||||
|
|
||||||
@@ -294,7 +322,7 @@ category 对应的关键词有
|
|||||||
| -------- | ---------------- | ---------- | ---------- | ---------- | ---------- | ---------- | ---------- | ---------- |
|
| -------- | ---------------- | ---------- | ---------- | ---------- | ---------- | ---------- | ---------- | ---------- |
|
||||||
| 國內綜合 | 政治・經濟 | 文化・生活 | 旅遊・活動 | 體育・奧運 | 商業・商品 | IT・科技 | 國際・東亞 | 評論・專欄 |
|
| 國內綜合 | 政治・經濟 | 文化・生活 | 旅遊・活動 | 體育・奧運 | 商業・商品 | IT・科技 | 國際・東亞 | 評論・專欄 |
|
||||||
|
|
||||||
版块 `cool_japan` 和 `travel` 包含子板块子板块:
|
版块 `cool_japan` 和 `travel` 包含子版块:
|
||||||
|
|
||||||
`cool_japan`:
|
`cool_japan`:
|
||||||
|
|
||||||
|
|||||||
@@ -1260,7 +1260,11 @@ router.get('/the-economist/gre-vocabulary', require('./routes/the-economist/gre-
|
|||||||
// 鼠绘漫画
|
// 鼠绘漫画
|
||||||
router.get('/shuhui/comics/:id', require('./routes/shuhui/comics'));
|
router.get('/shuhui/comics/:id', require('./routes/shuhui/comics'));
|
||||||
|
|
||||||
// 朝日新聞中文網
|
// 朝日新聞中文网(简体中文版)
|
||||||
|
router.get('/asahichinese-j/:category/:subCate', require('./routes/asahichinese-j/index'));
|
||||||
|
router.get('/asahichinese-j/:category', require('./routes/asahichinese-j/index'));
|
||||||
|
|
||||||
|
// 朝日新聞中文網(繁體中文版)
|
||||||
router.get('/asahichinese-f/:category/:subCate', require('./routes/asahichinese-f/index'));
|
router.get('/asahichinese-f/:category/:subCate', require('./routes/asahichinese-f/index'));
|
||||||
router.get('/asahichinese-f/:category', require('./routes/asahichinese-f/index'));
|
router.get('/asahichinese-f/:category', require('./routes/asahichinese-f/index'));
|
||||||
|
|
||||||
|
|||||||
109
lib/routes/asahichinese-j/index.js
Normal file
109
lib/routes/asahichinese-j/index.js
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
const axios = require('@/utils/axios');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
const logger = require('@/utils/logger');
|
||||||
|
|
||||||
|
const categoryCodes = new Map([
|
||||||
|
['society', { name: '日本社会', types: {} }],
|
||||||
|
['politics_economy', { name: '政治・经济', types: {} }],
|
||||||
|
[
|
||||||
|
'cool_japan',
|
||||||
|
{
|
||||||
|
name: '文娱・生活',
|
||||||
|
types: {
|
||||||
|
entertainment: '艺能',
|
||||||
|
anime: '动漫',
|
||||||
|
life: '生活・美食',
|
||||||
|
style_culture: '时尚・文化',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'travel',
|
||||||
|
{
|
||||||
|
name: '旅游・活动',
|
||||||
|
types: {
|
||||||
|
news: '资讯',
|
||||||
|
scenery: '风景',
|
||||||
|
topic: '体验',
|
||||||
|
move: '交通',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
['sports', { name: '体育・奥运', types: {} }],
|
||||||
|
['business', { name: '商务・商品', types: {} }],
|
||||||
|
['technology', { name: 'IT・科技', types: {} }],
|
||||||
|
['world', { name: '国际・东亚', types: {} }],
|
||||||
|
['opinion', { name: '观点・专栏', types: {} }],
|
||||||
|
]);
|
||||||
|
|
||||||
|
const host = 'https://asahichinese-j.com';
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const category = ctx.params.category;
|
||||||
|
const type = ctx.params.subCate;
|
||||||
|
let iTitle = categoryCodes.get(category).name;
|
||||||
|
|
||||||
|
let link = `https://asahichinese-j.com/${category}/`;
|
||||||
|
if (type !== undefined) {
|
||||||
|
link = link + `${type}/`;
|
||||||
|
iTitle = iTitle + '-' + categoryCodes.get(category).types[type];
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await axios.get(link);
|
||||||
|
|
||||||
|
const $ = cheerio.load(response.data);
|
||||||
|
|
||||||
|
const list = $('ul.List li')
|
||||||
|
.slice(1, 11)
|
||||||
|
.map(function() {
|
||||||
|
const info = {
|
||||||
|
title: $(this)
|
||||||
|
.find('a')
|
||||||
|
.text(),
|
||||||
|
link: $(this)
|
||||||
|
.find('a')
|
||||||
|
.attr('href'),
|
||||||
|
date: $(this)
|
||||||
|
.find('span.Date')
|
||||||
|
.text(),
|
||||||
|
};
|
||||||
|
logger.info(info.date);
|
||||||
|
return info;
|
||||||
|
})
|
||||||
|
.get();
|
||||||
|
|
||||||
|
const out = await Promise.all(
|
||||||
|
list.map(async (info) => {
|
||||||
|
const title = info.title;
|
||||||
|
const date = info.date;
|
||||||
|
const itemUrl = host + info.link;
|
||||||
|
|
||||||
|
const cache = await ctx.cache.get(itemUrl);
|
||||||
|
if (cache) {
|
||||||
|
return Promise.resolve(JSON.parse(cache));
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await axios.get(itemUrl);
|
||||||
|
|
||||||
|
const $ = cheerio.load(response.data);
|
||||||
|
const description = $('div.ArticleText')
|
||||||
|
.html()
|
||||||
|
.trim();
|
||||||
|
|
||||||
|
const single = {
|
||||||
|
title: title,
|
||||||
|
link: itemUrl,
|
||||||
|
description: description,
|
||||||
|
pubDate: new Date(date).toUTCString(),
|
||||||
|
};
|
||||||
|
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||||
|
return Promise.resolve(single);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: `${iTitle}-朝日新聞中文网`,
|
||||||
|
link: link,
|
||||||
|
item: out,
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user