mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-08 14:07:54 +08:00
@@ -217,3 +217,29 @@ category 对应的关键词有
|
|||||||
## The Economist
|
## The Economist
|
||||||
|
|
||||||
<Route name="GRE Vocabulary" author="xyqfer" example="/the-economist/gre-vocabulary" path="/the-economist/gre-vocabulary" />
|
<Route name="GRE Vocabulary" author="xyqfer" example="/the-economist/gre-vocabulary" path="/the-economist/gre-vocabulary" />
|
||||||
|
|
||||||
|
## 朝日新聞中文網
|
||||||
|
|
||||||
|
<Route name="新闻分类" author="qiwihui" example="/sina/society" path="/sina/discovery/: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>
|
||||||
|
|||||||
@@ -1319,4 +1319,8 @@ router.get('/gradcafe/result', require('./routes/gradcafe/result'));
|
|||||||
// The Economist
|
// The Economist
|
||||||
router.get('/the-economist/gre-vocabulary', require('./routes/the-economist/gre-vocabulary'));
|
router.get('/the-economist/gre-vocabulary', require('./routes/the-economist/gre-vocabulary'));
|
||||||
|
|
||||||
|
// 朝日新聞中文網
|
||||||
|
router.get('/asahichinese-f/:category/:subCate', require('./routes/asahichinese-f/index'));
|
||||||
|
router.get('/asahichinese-f/:category', require('./routes/asahichinese-f/index'));
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
109
lib/routes/asahichinese-f/index.js
Normal file
109
lib/routes/asahichinese-f/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-f.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-f.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), 24 * 60 * 60);
|
||||||
|
return Promise.resolve(single);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: `${iTitle}-朝日新聞中文網`,
|
||||||
|
link: link,
|
||||||
|
item: out,
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user