mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-21 12:49:53 +08:00
feat: 增加安全客获取全文 (#10921)
* feat: 增加安全客获取全文 * fix: 不需要控制台输出 * fix: const single * fix: 不分状态获取全文 现在仅在添加了 `fulltext` 或 `quanwen` 时才获取全文 * docs: 添加安全客获取全文参数说明 * docs: 删除重复的内容
This commit is contained in:
+1
-1
@@ -720,7 +720,7 @@ GitHub 官方也提供了一些 RSS:
|
||||
|
||||
### 分类订阅
|
||||
|
||||
<Route author="qwertyuiop6" example="/anquanke/week" path="/anquanke/:category" :paramsDesc="['分类订阅']" radar="1" rssbud="1">
|
||||
<Route author="qwertyuiop6" example="/anquanke/week" path="/anquanke/:category/:fulltext?" :paramsDesc="['分类订阅', '是否获取全文,如需获取全文参数传入 `quanwen` 或 `fulltext`']" radar="1" rssbud="1">
|
||||
|
||||
| 360 网络安全周报 | 活动 | 知识 | 资讯 | 招聘 | 工具 |
|
||||
| ---------- | -------- | --------- | ---- | --- | ---- |
|
||||
|
||||
@@ -1,20 +1,32 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const api = 'https://api.anquanke.com/data/v1/posts?size=10&page=1&category=';
|
||||
const type = ctx.params.category;
|
||||
const fulltext = ctx.params.fulltext;
|
||||
const host = 'https://www.anquanke.com';
|
||||
const res = await got(`${api}${type}`);
|
||||
const dataArray = res.data.data;
|
||||
|
||||
const items = dataArray.map((item) => ({
|
||||
title: item.title,
|
||||
description: item.desc,
|
||||
pubDate: timezone(parseDate(item.date), +8),
|
||||
link: `${host}/${type === 'week' ? 'week' : 'post'}/id/${item.id}`,
|
||||
author: item.author.nickname,
|
||||
const items = await Promise.all(
|
||||
dataArray.map(async (item) => {
|
||||
const art_url = `${host}/${type === 'week' ? 'week' : 'post'}/id/${item.id}`;
|
||||
return {
|
||||
title: item.title,
|
||||
description: fulltext === 'fulltext' || fulltext === 'quanwen'
|
||||
? await ctx.cache.tryGet(art_url, async () => {
|
||||
const { data: res } = await got(art_url);
|
||||
const content = cheerio.load(res);
|
||||
return content('#js-article').html();
|
||||
})
|
||||
: item.desc,
|
||||
pubDate: timezone(parseDate(item.date), +8),
|
||||
link: art_url,
|
||||
author: item.author.nickname,
|
||||
};
|
||||
}));
|
||||
|
||||
ctx.state.data = {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
// '/vul': ['qwertyuiop6'],
|
||||
'/:category': ['qwertyuiop6'],
|
||||
'/:category/:fulltext?': ['qwertyuiop6'],
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module.exports = (router) => {
|
||||
// router.get('/vul', require('./vul')); // 404
|
||||
router.get('/:category', require('./category'));
|
||||
router.get('/:category/:fulltext?', require('./category'));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user