diff --git a/README.md b/README.md index 94cda72c02..c6a338055d 100644 --- a/README.md +++ b/README.md @@ -172,6 +172,8 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇 - 标签 - 草榴 - 分区帖子 +- 科技星球 + - 首页 ## 鸣谢 diff --git a/docs/README.md b/docs/README.md index 225c3f5534..9d95ad81a3 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1419,3 +1419,11 @@ id, 专辑 id, 可在对应专辑页面的 URL 中找到 | 技术讨论区 | 新时代的我们 | 达盖尔的旗帜 | | ---------- | ------------ | ------------ | | 7 | 8 | 16 | + +## 科技星球 + +### 首页 + +举例: [https://rsshub.app/kejixingqiu/home](https://rsshub.app/kejixingqiu/home) + +路由: `/kejixingqiu/home` \ No newline at end of file diff --git a/router.js b/router.js index 741a78261b..491fce99a9 100644 --- a/router.js +++ b/router.js @@ -331,4 +331,7 @@ router.get('/cctv/:category', require('./routes/cctv/category')); // 草榴社区 router.get('/t66y/:id', require('./routes/t66y/index')); +// 科技星球 +router.get('/kejixingqiu/home', require('./routes/kejixingqiu/home')); + module.exports = router; diff --git a/routes/kejixingqiu/home.js b/routes/kejixingqiu/home.js new file mode 100644 index 0000000000..78ac259ad9 --- /dev/null +++ b/routes/kejixingqiu/home.js @@ -0,0 +1,39 @@ +const axios = require('../../utils/axios'); +const cheerio = require('cheerio'); +const config = require('../../config'); + +module.exports = async (ctx) => { + const response = await axios({ + method: 'get', + url: 'http://www.xincheng.tv', + headers: { + 'User-Agent': config.ua, + }, + }); + + const data = response.data; + + const $ = cheerio.load(data); + const list = $('.l-news_item'); + + ctx.state.data = { + title: $('title').text(), + link: 'http://www.xincheng.tv', + description: $('meta[name="description"]').attr('content'), + item: + list && + list + .map((index, item) => { + item = $(item); + return { + title: `${item.find('.sub1-titile2').text()} - ${item.find('.sub1-titile1').text()}`, + description: item.find('.sub1-new-item').text(), + link: `http://www.xincheng.tv${item + .find('.sub1-titile2') + .parent() + .attr('href')}`, + }; + }) + .get(), + }; +};