mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-08 05:59:00 +08:00
add zaker (#1869)
This commit is contained in:
@@ -462,6 +462,10 @@ type 为 all 时,category 参数不支持 cost 和 free
|
||||
|
||||
<route name="产业研究报告" author="brilon" example="/iresearch/report" path="/iresearch/report"/>
|
||||
|
||||
### ZAKER
|
||||
|
||||
<Route name="source" author="LogicJake" example="/zaker/source/12291" path="/zaker/source/:id" :paramsDesc="['source id,可在 URL 中找到']"/>
|
||||
|
||||
### MobData
|
||||
|
||||
<route name="分析报告" author="brilon" example="/mobdata/report" path="/mobdata/report"/>
|
||||
|
||||
@@ -1227,6 +1227,9 @@ router.get('/checkee/:dispdate', require('./routes/checkee/index'));
|
||||
// 艾瑞
|
||||
router.get('/iresearch/report', require('./routes/iresearch/report'));
|
||||
|
||||
// ZAKER
|
||||
router.get('/zaker/source/:id', require('./routes/zaker/source'));
|
||||
|
||||
// Matters
|
||||
router.get('/matters/topics', require('./routes/matters/topics'));
|
||||
router.get('/matters/latest', require('./routes/matters/latest'));
|
||||
|
||||
69
lib/routes/zaker/source.js
Normal file
69
lib/routes/zaker/source.js
Normal file
@@ -0,0 +1,69 @@
|
||||
const axios = require('../../utils/axios');
|
||||
const cheerio = require('cheerio');
|
||||
const date_util = require('../../utils/date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id;
|
||||
const link = `http://www.myzaker.com/source/${id}`;
|
||||
|
||||
const response = await axios.get(link);
|
||||
const $ = cheerio.load(response.data);
|
||||
const title = $('a.nav_item_active').text();
|
||||
|
||||
const list = $('div.figure.flex-block')
|
||||
.slice(0, 10)
|
||||
.map(function() {
|
||||
const info = {
|
||||
title: $(this)
|
||||
.find('h2 a')
|
||||
.attr('title'),
|
||||
link: $(this)
|
||||
.find('h2 a')
|
||||
.attr('href'),
|
||||
};
|
||||
return info;
|
||||
})
|
||||
.get();
|
||||
|
||||
const out = await Promise.all(
|
||||
list.map(async (info) => {
|
||||
const title = info.title;
|
||||
const itemUrl = 'http:' + info.link;
|
||||
|
||||
const cache = await ctx.cache.get(itemUrl);
|
||||
if (cache) {
|
||||
return Promise.resolve(JSON.parse(cache));
|
||||
}
|
||||
|
||||
const response = await axios({
|
||||
url: itemUrl,
|
||||
method: 'get',
|
||||
headers: {
|
||||
Referer: link,
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0',
|
||||
},
|
||||
});
|
||||
const $ = cheerio.load(response.data);
|
||||
const description = $('div.article_content div')
|
||||
.html()
|
||||
.replace(/data-original/g, `src`);
|
||||
|
||||
const date = $('span.time').text();
|
||||
|
||||
const single = {
|
||||
title: title,
|
||||
link: itemUrl,
|
||||
description: description,
|
||||
pubDate: date_util(date, 8),
|
||||
};
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${title}-ZAKER新闻`,
|
||||
link: link,
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user