diff --git a/README.md b/README.md index d244c8ca2..a34f1e2ef 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,8 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇 - 开发者头条 - 今天头条 - 独家号 +- 极客时间 + - 专栏文章 - Disqus - 评论 - Twitter diff --git a/docs/README.md b/docs/README.md index e06f4395d..a7ecb2797 100644 --- a/docs/README.md +++ b/docs/README.md @@ -217,7 +217,7 @@ order: 排序方式,live_time 开播时间,online 人气 参数 -areaID: 分区ID 分区增删较多,可通过 [分区列表](https://api.live.bilibili.com/room/v1/Area/getList) 查询 +areaID: 分区ID 分区增删较多,可通过 [分区列表](https://api.live.bilibili.com/room/v1/Area/getList) 查询 order: 排序方式,live_time 开播时间,online 人气 @@ -639,6 +639,18 @@ key: 产品密钥 参数: id,独家号 id,可在对应独家号页 URL 中找到 +## 极客时间 + +### 专栏文章 + +> 极客时间专栏需要付费订阅,RSS 仅做更新提醒,不含付费内容。 + +举例: [https://rsshub.app/geektime/column/48](https://rsshub.app/geektime/column/48) + +路由: `/geektime/column/:cid` + +参数: cid,专栏 id,可从[全部专栏](https://time.geekbang.org/paid-content)进入专栏介绍页,在 URL 中找到 + ## Disqus ### 评论 diff --git a/router.js b/router.js index cbfa4f9c4..69b8f0533 100644 --- a/router.js +++ b/router.js @@ -134,4 +134,7 @@ if (config.youtube && config.youtube.key) { router.get('/jike/topic/:id', require('./routes/jike/topic')); router.get('/jike/user/:id', require('./routes/jike/user')); +// 极客时间 +router.get('/geektime/column/:cid', require('./routes/geektime/column')); + module.exports = router; diff --git a/routes/geektime/column.js b/routes/geektime/column.js new file mode 100644 index 000000000..84c8463a2 --- /dev/null +++ b/routes/geektime/column.js @@ -0,0 +1,50 @@ +const axios = require('axios'); +const config = require('../../config'); + +module.exports = async (ctx) => { + const column_id = ctx.params.cid; + + // Get column introduction including column name and description + const intro_response = await axios({ + method: 'post', + url: 'https://time.geekbang.org/serv/v1/column/intro', + headers: { + 'User-Agent': config.ua, + 'Referer': 'https://time.geekbang.org/', + 'Content-Type': 'application/json' + }, + data: { + cid: column_id + } + }); + + const intro_data = intro_response.data.data; + + // Get latest articles + const latest_response = await axios({ + method: 'post', + url: 'https://time.geekbang.org/serv/v1/column/articles/latest', + headers: { + 'User-Agent': config.ua, + 'Referer': 'https://time.geekbang.org/', + 'Content-Type': 'application/json' + }, + data: { + cid: column_id + } + }); + + const articles = latest_response.data.data.list; + + ctx.state.data = { + title: intro_data.column_title, + link: `https://time.geekbang.org/column/intro/${column_id}`, + description: intro_data.column_subtitle, + item: articles.map((item) => ({ + title: item.article_title, + description: item.article_summary, + pubDate: new Date(item.article_ctime * 1000).toUTCString(), + link: `https://time.geekbang.org/column/article/${item.id}` + })), + }; +}; \ No newline at end of file