mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 23:00:48 +08:00
@@ -2805,3 +2805,7 @@ board 和 build 可在[这里](http://api.ineal.me/tss/status)查看
|
||||
### 多抓鱼
|
||||
|
||||
<route name="搜索结果" author="fengkx" example="/duozhuayu/search/JavaScript" path="/duozhuayu/search/:wd" :paramsDesc="['搜索关键词']"/>
|
||||
|
||||
### 创业邦
|
||||
|
||||
<route name="作者" author="xyqfer" example="/cyzone/author/1225562" path="/cyzone/author/:id" :paramsDesc="['作者 id']"/>
|
||||
|
||||
@@ -995,4 +995,7 @@ router.get('/wallstreetcn/news/global', require('./routes/wallstreetcn/news'));
|
||||
// 多抓鱼搜索
|
||||
router.get('/duozhuayu/search/:wd', require('./routes/duozhuayu/search'));
|
||||
|
||||
// 创业邦
|
||||
router.get('/cyzone/author/:id', require('./routes/cyzone/author'));
|
||||
|
||||
module.exports = router;
|
||||
|
||||
56
lib/routes/cyzone/author.js
Normal file
56
lib/routes/cyzone/author.js
Normal file
@@ -0,0 +1,56 @@
|
||||
const cheerio = require('cheerio');
|
||||
const axios = require('../../utils/axios');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { id } = ctx.params;
|
||||
const url = `https://www.cyzone.cn/author/${id}`;
|
||||
const res = await axios.get(url);
|
||||
const data = res.data;
|
||||
const $ = cheerio.load(data);
|
||||
|
||||
const list = $('.article-item');
|
||||
|
||||
const out = await Promise.all(
|
||||
list
|
||||
.map(async (index, elem) => {
|
||||
const $elem = $(elem);
|
||||
const $title = $elem.find('.item-title');
|
||||
const link = 'https:' + $title.attr('href');
|
||||
const pubDate = new Date(+$elem.find('.time').attr('data-time') * 1000).toUTCString();
|
||||
const item = {
|
||||
title: $title.text(),
|
||||
pubDate,
|
||||
link,
|
||||
};
|
||||
const key = `cyzone-${link}`;
|
||||
const value = await ctx.cache.get(key);
|
||||
if (value) {
|
||||
item.description = value;
|
||||
} else {
|
||||
const storyDetail = await axios.get(item.link);
|
||||
const data = storyDetail.data;
|
||||
const $ = cheerio.load(data);
|
||||
$('.article-content img').each(function() {
|
||||
const $img = $(this);
|
||||
const src = $img.attr('src');
|
||||
|
||||
if (!src.startsWith('http')) {
|
||||
$img.attr('src', 'https:' + src);
|
||||
}
|
||||
});
|
||||
item.description = $('.article-content').html();
|
||||
ctx.cache.set(key, item.description, 12 * 60 * 60);
|
||||
}
|
||||
|
||||
return Promise.resolve(item);
|
||||
})
|
||||
.get()
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `创业邦-作者 ${$('.ss-title').text()}`,
|
||||
link: url,
|
||||
description: '创业邦致力于成为中国创业者的信息平台和服务平台,帮助中国创业者实现创业梦想。创业邦为创业者和风险投资人提供各种创业类最新资讯和实用知识手册,打造创业者和投资人的社交平台。',
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user