feat: 添加镁客网im2maker RSS (#2607)
This commit is contained in:
parent
43db2dbf96
commit
219ea0dcd3
|
|
@ -606,6 +606,18 @@ type 为 all 时,category 参数不支持 cost 和 free
|
|||
|
||||
<Route author="junfengP" example="/mlhang" path="/mlhang" />
|
||||
|
||||
## 镁客网 im2maker
|
||||
|
||||
### 镁客网频道
|
||||
|
||||
<Route author="jin12180000" example="/im2maker/" path="/ifanr/:channel?" :paramsDesc="['默认不填为 最新文章 ,频道如下']">
|
||||
|
||||
| 最新文章 | 行业快讯 | 行业观察 | 镁客请讲 | 硬科技 100 人 | 投融界 | 万象 |
|
||||
| -------- | -------- | -------- | -------- | ------------- | -------- | ---------- |
|
||||
| 默认空 | fresh | industry | talk | intech | investor | everything |
|
||||
|
||||
</Route>
|
||||
|
||||
## 每日安全
|
||||
|
||||
### 推送
|
||||
|
|
|
|||
|
|
@ -1495,6 +1495,9 @@ router.get('/aptonic/action', require('./routes/aptonic/action'));
|
|||
// 印记中文周刊
|
||||
router.get('/docschina/jsweekly', require('./routes/docschina/jsweekly'));
|
||||
|
||||
// im2maker
|
||||
router.get('/im2maker/:channel?', require('./routes/im2maker/index'));
|
||||
|
||||
// 巨潮资讯
|
||||
router.get('/cninfo/stock_announcement/:code', require('./routes/cninfo/stock_announcement'));
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,60 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
const category = {
|
||||
default: '最新文章',
|
||||
fresh: '行业快讯',
|
||||
industry: '行业观察',
|
||||
talk: '镁客请讲',
|
||||
intech: '硬科技100人',
|
||||
investor: '投融界',
|
||||
everything: '万象',
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
let host = 'https://www.im2maker.com';
|
||||
|
||||
let channel = 'default';
|
||||
if (ctx.params.channel) {
|
||||
channel = ctx.params.channel.toLowerCase();
|
||||
host = `${host}/category/${channel}`;
|
||||
}
|
||||
const titleCategory = category[channel];
|
||||
|
||||
const response = await got.get(host);
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const hrefs = $("a[class='title info_flow_news_title']")
|
||||
.map((i, e) => e.attribs.href)
|
||||
.get();
|
||||
|
||||
const out = await Promise.all(
|
||||
hrefs.map(async (itemUrl) => {
|
||||
const cache = await ctx.cache.get(itemUrl);
|
||||
if (cache) {
|
||||
return Promise.resolve(JSON.parse(cache));
|
||||
}
|
||||
|
||||
const response = await got.get(itemUrl);
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const item = {
|
||||
title: $('title').text(),
|
||||
link: itemUrl,
|
||||
author: $('.single-post-header-meta .author .name').text(),
|
||||
description: $('.article').html(),
|
||||
pubDate: $('.single-post-header-meta .author .item').text(),
|
||||
};
|
||||
|
||||
ctx.cache.set(itemUrl, JSON.stringify(item));
|
||||
return Promise.resolve(item);
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `镁客网 ${titleCategory}`,
|
||||
link: host,
|
||||
description: '镁客网',
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue