添加科技星球首页更新 (#344)

This commit is contained in:
vhgyux
2018-07-07 10:34:30 +08:00
committed by DIYgod
parent cc0ca6f255
commit 31c3328845
4 changed files with 52 additions and 0 deletions

View File

@@ -172,6 +172,8 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇
- 标签
- 草榴
- 分区帖子
- 科技星球
- 首页
## 鸣谢

View File

@@ -1419,3 +1419,11 @@ id, 专辑 id, 可在对应专辑页面的 URL 中找到
| 技术讨论区 | 新时代的我们 | 达盖尔的旗帜 |
| ---------- | ------------ | ------------ |
| 7 | 8 | 16 |
## 科技星球
### 首页
举例: [https://rsshub.app/kejixingqiu/home](https://rsshub.app/kejixingqiu/home)
路由: `/kejixingqiu/home`

View File

@@ -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;

View File

@@ -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(),
};
};