mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat: add 无产者评论 (#6376)
This commit is contained in:
@@ -1753,6 +1753,30 @@ column 为 third 时可选的 category:
|
||||
|
||||
<Route author="xyqfer" example="/wechat/miniprogram/plugins" path="/wechat/miniprogram/plugins" />
|
||||
|
||||
## 无产者评论
|
||||
|
||||
### 分类
|
||||
|
||||
<Route author="nczitzk" example="/proletar" path="/proletar/categories/:id?" :paramsDesc="['分类,见下表,默认为全部文章']">
|
||||
|
||||
| 全部文章 | 中流击水 | 革命文艺 | 当代中国 | 理论视野 | 国际观察 | 史海沉钩 |
|
||||
| -------- | -------- | -------- | -------- | -------- | -------- | -------- |
|
||||
| | 中流击水 | 革命文艺 | 当代中国 | 理论视野 | 国际观察 | 史海沉钩 |
|
||||
|
||||
</Route>
|
||||
|
||||
### 标签
|
||||
|
||||
<Route author="nczitzk" example="/proletar" path="/proletar/tags/:id?" :paramsDesc="['标签,默认为全部文章']">
|
||||
|
||||
::: tip 提示
|
||||
|
||||
标签名参见 [所有标签](https://review.proletar.ink/tags)
|
||||
|
||||
:::
|
||||
|
||||
</Route>
|
||||
|
||||
## 西祠胡同
|
||||
|
||||
### 频道
|
||||
|
||||
@@ -3661,6 +3661,9 @@ router.get('/tesla', require('./routes/tesla/update'));
|
||||
// 复旦大学继续教育学院
|
||||
router.get('/fudan/cce', require('./routes/universities/fudan/cce'));
|
||||
|
||||
// 无产者评论
|
||||
router.get('/proletar/:type?/:id?', require('./routes/proletar/index'));
|
||||
|
||||
// QTTabBar
|
||||
router.get('/qttabbar/change-log', require('./routes/qttabbar/change-log'));
|
||||
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const type = ctx.params.type || '';
|
||||
const id = ctx.params.id || '';
|
||||
|
||||
const rootUrl = 'https://review.proletar.ink';
|
||||
const currentUrl = `${rootUrl}/${type === '' && id === '' ? 'posts' : `${type}/${id}`}`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('.archive-item-link')
|
||||
.slice(0, 15)
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
title: item.text(),
|
||||
link: `${rootUrl}${item.attr('href')}`,
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map(
|
||||
async (item) =>
|
||||
await ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
item.author = content('.post-author').text();
|
||||
item.description = content('#content').html();
|
||||
item.pubDate = new Date(detailResponse.data.match(/"datePublished":"(.*)","dateModified"/)[1]).toUTCString();
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user