mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-14 09:12:01 +08:00
增加:看雪论坛主题帖 (#854)
This commit is contained in:
@@ -602,6 +602,31 @@ GitHub 官方也提供了一些 RSS:
|
|||||||
|
|
||||||
<route name="博文" author="imlonghao" example="/linkedkeeper/sub/1" path="/linkedkeeper/:type/:id?" :paramsDesc="['博文分类, 为 URL 中 `.action` 的文件名', '分区或标签的 ID, 对应 URL 中的 `sid` 或 `tid`']"/>
|
<route name="博文" author="imlonghao" example="/linkedkeeper/sub/1" path="/linkedkeeper/:type/:id?" :paramsDesc="['博文分类, 为 URL 中 `.action` 的文件名', '分区或标签的 ID, 对应 URL 中的 `sid` 或 `tid`']"/>
|
||||||
|
|
||||||
|
### 看雪
|
||||||
|
|
||||||
|
<route name="论坛" author="renzhexigua" example="/pediy/topic/android/digest" path="/pediy/topic/:category?/:type?" :paramsDesc="['版块, 缺省为`all`', '类型, 缺省为`latest`']"/>
|
||||||
|
|
||||||
|
| 版块 | category |
|
||||||
|
| ------------ | ---------- |
|
||||||
|
| 智能设备 | iot |
|
||||||
|
| 区块链安全 | blockchain |
|
||||||
|
| Android 安全 | android |
|
||||||
|
| iOS 安全 | ios |
|
||||||
|
| 软件逆向 | re |
|
||||||
|
| 编程技术 | coding |
|
||||||
|
| 加壳脱壳 | unpack |
|
||||||
|
| 密码算法 | crypto |
|
||||||
|
| 二进制漏洞 | vuln |
|
||||||
|
| CrackMe | crackme |
|
||||||
|
| Pwn | pwn |
|
||||||
|
| WEB 安全 | web |
|
||||||
|
| 全站 | all |
|
||||||
|
|
||||||
|
| 类型 | type |
|
||||||
|
| -------- | ------ |
|
||||||
|
| 最新主题 | latest |
|
||||||
|
| 精华主题 | digest |
|
||||||
|
|
||||||
## 直播
|
## 直播
|
||||||
|
|
||||||
### 哔哩哔哩直播
|
### 哔哩哔哩直播
|
||||||
|
|||||||
@@ -614,4 +614,7 @@ router.get('/ft/chinese/:channel?', require('./routes/ft/chinese'));
|
|||||||
// The Verge
|
// The Verge
|
||||||
router.get('/verge', require('./routes/verge/index'));
|
router.get('/verge', require('./routes/verge/index'));
|
||||||
|
|
||||||
|
// 看雪
|
||||||
|
router.get('/pediy/topic/:category?/:type?', require('./routes/pediy/topic'));
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
95
routes/pediy/topic.js
Normal file
95
routes/pediy/topic.js
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
const axios = require('../../utils/axios');
|
||||||
|
const dateHelper = require('../../utils/date');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
|
||||||
|
const baseUrl = 'https://bbs.pediy.com/';
|
||||||
|
const categoryId = {
|
||||||
|
iot: [128, '智能设备'],
|
||||||
|
blockchain: [172, '区块链安全'],
|
||||||
|
android: [161, 'Android安全'],
|
||||||
|
ios: [166, 'iOS安全'],
|
||||||
|
re: [4, '软件逆向'],
|
||||||
|
coding: [41, '编程技术'],
|
||||||
|
unpack: [88, '加壳脱壳'],
|
||||||
|
crypto: [132, '密码算法'],
|
||||||
|
vuln: [150, '二进制漏洞'],
|
||||||
|
crackme: [37, 'CrackMe'],
|
||||||
|
pwn: [171, 'Pwn'],
|
||||||
|
web: [151, 'WEB安全'],
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const category = ctx.params.category || 'all';
|
||||||
|
const type = ctx.params.type || 'latest';
|
||||||
|
let path;
|
||||||
|
let title;
|
||||||
|
let isSpecific;
|
||||||
|
|
||||||
|
if (categoryId.hasOwnProperty(category)) {
|
||||||
|
isSpecific = true;
|
||||||
|
if (type === 'digest') {
|
||||||
|
// type为digest时只获取精华帖
|
||||||
|
path = `forum-${categoryId[category][0]}-1.htm?digest=1`;
|
||||||
|
title = `看雪论坛精华主题 - ${categoryId[category][1]}`;
|
||||||
|
} else {
|
||||||
|
// type为空/非法/latest时则只获取最新帖
|
||||||
|
path = `forum-${categoryId[category][0]}.html`;
|
||||||
|
title = `看雪论坛最新主题 - ${categoryId[category][1]}`;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// category未知时则获取全站最新帖
|
||||||
|
isSpecific = false;
|
||||||
|
if (category === 'digest') {
|
||||||
|
path = 'new-digest.htm';
|
||||||
|
title = '看雪论坛精华主题';
|
||||||
|
} else {
|
||||||
|
path = 'new-tid.htm';
|
||||||
|
title = '看雪论坛最新主题';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await axios({
|
||||||
|
method: 'get',
|
||||||
|
url: baseUrl + path,
|
||||||
|
headers: {
|
||||||
|
Referer: baseUrl,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = response.data;
|
||||||
|
const $ = cheerio.load(data);
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: `${title}`,
|
||||||
|
link: baseUrl + path,
|
||||||
|
item: $('.thread')
|
||||||
|
.map((_, elem) => {
|
||||||
|
const subject = $('.subject a', elem).eq(1);
|
||||||
|
const author = $('.username', elem).eq(0);
|
||||||
|
|
||||||
|
let pubDate = $('.date', elem).eq(0);
|
||||||
|
if (pubDate.text().indexOf('前') !== -1) {
|
||||||
|
pubDate = dateHelper(pubDate.text(), 8);
|
||||||
|
} else {
|
||||||
|
pubDate = pubDate.text();
|
||||||
|
}
|
||||||
|
|
||||||
|
let topic;
|
||||||
|
if (isSpecific) {
|
||||||
|
topic = categoryId[category][1];
|
||||||
|
} else {
|
||||||
|
topic = $('.subject a.small', elem)
|
||||||
|
.eq(0)
|
||||||
|
.text();
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
title: subject.text(),
|
||||||
|
link: baseUrl + subject.attr('href'),
|
||||||
|
pubDate: pubDate,
|
||||||
|
description: `作者: ${author.text()} 版块: ${topic}`,
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.get(),
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user