mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-10 15:21:59 +08:00
feat: add aisixiang thinktank (#4735)
This commit is contained in:
@@ -32,6 +32,16 @@ pageClass: routes
|
|||||||
|
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
|
### 思想库(专栏)
|
||||||
|
|
||||||
|
<Route author="hoilc" example="/aisixiang/thinktank/WuQine/lunw" path="/aisixiang/thinktank/:name/:type?" :paramsDesc="['专栏 ID,一般为作者拼音,可在URL中找到', '栏目类型,参考下表,默认为`lunw`']">
|
||||||
|
|
||||||
|
| 论文 | 时评 | 随笔 | 演讲 | 访谈 | 著作 | 读书 | 史论 | 译作 | 诗歌 | 书信 | 科学 |
|
||||||
|
| ---- | ---- | ----- | ---- | ----- | ------ | ----- | ------ | ----- | ----- | ------ | ----- |
|
||||||
|
| lunw | ship | shuib | yanj | fangt | zhuanz | dushu | shilun | yizuo | shige | shuxin | kexue |
|
||||||
|
|
||||||
|
</Route>
|
||||||
|
|
||||||
## 爱下电子书
|
## 爱下电子书
|
||||||
|
|
||||||
### 最新章节
|
### 最新章节
|
||||||
|
|||||||
@@ -1259,6 +1259,7 @@ router.get('/whalegogo/portal/:type_id/:tagid?', require('./routes/whalegogo/por
|
|||||||
// 爱思想
|
// 爱思想
|
||||||
router.get('/aisixiang/column/:id', require('./routes/aisixiang/column'));
|
router.get('/aisixiang/column/:id', require('./routes/aisixiang/column'));
|
||||||
router.get('/aisixiang/ranking/:type?/:range?', require('./routes/aisixiang/ranking'));
|
router.get('/aisixiang/ranking/:type?/:range?', require('./routes/aisixiang/ranking'));
|
||||||
|
router.get('/aisixiang/thinktank/:name/:type?', require('./routes/aisixiang/thinktank'));
|
||||||
|
|
||||||
// Hacker News
|
// Hacker News
|
||||||
router.get('/hackernews/:section/:type?', require('./routes/hackernews/story'));
|
router.get('/hackernews/:section/:type?', require('./routes/hackernews/story'));
|
||||||
|
|||||||
40
lib/routes/aisixiang/thinktank.js
Normal file
40
lib/routes/aisixiang/thinktank.js
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
const iconv = require('iconv-lite');
|
||||||
|
const util = require('./utils');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const { name, type = 'lunw' } = ctx.params;
|
||||||
|
|
||||||
|
const host = `http://www.aisixiang.com/thinktank/${name}.html`;
|
||||||
|
|
||||||
|
const response = await got.get(host, {
|
||||||
|
responseType: 'buffer',
|
||||||
|
});
|
||||||
|
response.data = iconv.decode(response.data, 'gbk');
|
||||||
|
|
||||||
|
const $ = cheerio.load(response.data);
|
||||||
|
|
||||||
|
const tds = $('td > img').filter(function () {
|
||||||
|
return $(this).attr('src') === `images/${type}.gif`;
|
||||||
|
});
|
||||||
|
if (tds.length === 0) {
|
||||||
|
throw `Type Not Found - ${type}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const list = tds.parent().next().find('a').slice(0, 5).get();
|
||||||
|
|
||||||
|
const items = await Promise.all(
|
||||||
|
list.map(async (e) => {
|
||||||
|
const link = $(e).attr('href');
|
||||||
|
return await ctx.cache.tryGet(link, async () => await util.ProcessFeed(link));
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: $('title').text(),
|
||||||
|
link: host,
|
||||||
|
description: $('meta[name="description"]').attr('content'),
|
||||||
|
item: items,
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user