mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-10-24 23:42:40 +08:00
@@ -185,6 +185,8 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇
|
||||
- ONE · 一个
|
||||
- Firefox
|
||||
- Release note
|
||||
- 推酷
|
||||
- 周刊
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
@@ -1533,3 +1533,17 @@ id, 专辑 id, 可在对应专辑页面的 URL 中找到
|
||||
| 桌面 | Android | Beta | Nightly | Android Beta |
|
||||
| ------- | ------- | ---- | ------- | ------------ |
|
||||
| dekstop | android | beta | nightly | android-beta |
|
||||
|
||||
## 推酷
|
||||
|
||||
### 周刊
|
||||
|
||||
举例: [https://rsshub.app/tuicool/mags/tech](https://rsshub.app/tuicool/mags/tech)
|
||||
|
||||
路由: `/tuicool/mags/:type`
|
||||
|
||||
参数: type
|
||||
|
||||
| 编程狂人 | 设计匠艺 | 创业周刊 | 科技周刊 |
|
||||
| -------- | -------- | -------- | -------- |
|
||||
| prog | design | startup | tech |
|
||||
|
||||
@@ -351,4 +351,7 @@ router.get('/one', require('./routes/one/index'));
|
||||
// Firefox
|
||||
router.get('/firefox/release/:platform', require('./routes/firefox/release'));
|
||||
|
||||
// tuicool
|
||||
router.get('/tuicool/mags/:type', require('./routes/tuicool/mags'));
|
||||
|
||||
module.exports = router;
|
||||
|
||||
Executable
+56
@@ -0,0 +1,56 @@
|
||||
const axios = require('../../utils/axios');
|
||||
const cheerio = require('cheerio');
|
||||
const config = require('../../config');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const type = ctx.params.type;
|
||||
let url = `https://www.tuicool.com/mags/${type}`;
|
||||
if (type === 'prog') {
|
||||
url = 'https://www.tuicool.com/mags';
|
||||
}
|
||||
const res = await axios({
|
||||
method: 'get',
|
||||
url: url,
|
||||
headers: {
|
||||
'User-Agent': config.ua,
|
||||
},
|
||||
});
|
||||
url =
|
||||
'https://www.tuicool.com' +
|
||||
cheerio
|
||||
.load(res.data)('.mag-period-item a')
|
||||
.attr('href');
|
||||
|
||||
const response = await axios({
|
||||
method: 'get',
|
||||
url: url,
|
||||
headers: {
|
||||
'User-Agent': config.ua,
|
||||
},
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const list = $('.article-title');
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
link: 'https://www.tuicool.com/',
|
||||
item:
|
||||
list &&
|
||||
list
|
||||
.map((index, item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
title: item.find('.title').text(),
|
||||
description: `推酷:${item.find('.title').text()}`,
|
||||
pubDate: new Date(
|
||||
$('.period-title sub')
|
||||
.text()
|
||||
.substring(1, 11)
|
||||
).toUTCString(),
|
||||
link: `${item.find('a').attr('href')}`,
|
||||
};
|
||||
})
|
||||
.get(),
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user