mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 23:00:48 +08:00
增加艾瑞产业研究报告
This commit is contained in:
@@ -457,3 +457,7 @@ type 为 all 时,category 参数不支持 cost 和 free
|
|||||||
<Route name="推荐" author="brilon" example="/infoq/recommend" path="/infoq/recommend"/>
|
<Route name="推荐" author="brilon" example="/infoq/recommend" path="/infoq/recommend"/>
|
||||||
|
|
||||||
<Route name="话题" author="brilon" example="/infoq/topic/1" path="/infoq/topic/:id" :paramsDesc="['话题id,可在[InfoQ全部话题](https://www.infoq.cn/topics)页面找到URL里的话题id']" />
|
<Route name="话题" author="brilon" example="/infoq/topic/1" path="/infoq/topic/:id" :paramsDesc="['话题id,可在[InfoQ全部话题](https://www.infoq.cn/topics)页面找到URL里的话题id']" />
|
||||||
|
|
||||||
|
### 艾瑞
|
||||||
|
|
||||||
|
<route name="产业研究报告" author="brilon" example="/iresearch/report" path="/iresearch/report"/>
|
||||||
|
|||||||
@@ -1210,4 +1210,7 @@ router.get('/zju/career/:type', require('./routes/universities/zju/career'));
|
|||||||
router.get('/infoq/recommend', require('./routes/infoq/recommend'));
|
router.get('/infoq/recommend', require('./routes/infoq/recommend'));
|
||||||
router.get('/infoq/topic/:id', require('./routes/infoq/topic'));
|
router.get('/infoq/topic/:id', require('./routes/infoq/topic'));
|
||||||
|
|
||||||
|
// 艾瑞
|
||||||
|
router.get('/iresearch/report', require('./routes/iresearch/report'));
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
63
lib/routes/iresearch/report.js
Normal file
63
lib/routes/iresearch/report.js
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
const axios = require('../../utils/axios');
|
||||||
|
const date = require('../../utils/date');
|
||||||
|
async function processReport(item, ctx) {
|
||||||
|
const apiUrl = `http://www.iresearch.com.cn/Detail/reportM?id=${item.NewsId}&isfree=0`;
|
||||||
|
const pageUrl = 'http://www.iresearch.com.cn/m/report.shtml';
|
||||||
|
const cache = await ctx.cache.get(apiUrl);
|
||||||
|
if (cache) {
|
||||||
|
return cache;
|
||||||
|
}
|
||||||
|
const response = await axios({
|
||||||
|
method: 'get',
|
||||||
|
url: apiUrl,
|
||||||
|
headers: {
|
||||||
|
Referer: pageUrl,
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = response.data.List[0];
|
||||||
|
let description = data.Content + '<br>';
|
||||||
|
const reportId = data.id;
|
||||||
|
|
||||||
|
for (let i = 1; i <= data.PagesCount; i++) {
|
||||||
|
description += `<img src="http://report.iresearch.cn/rimgs/${reportId}/${i}.jpg" rel="noreferrer"><br>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
await ctx.cache.set(apiUrl, description, 24 * 60 * 60);
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const apiUrl = 'http://www.iresearch.com.cn/products/GetReportList?classId=&fee=0&date=&lastId=&pageSize=6';
|
||||||
|
const pageUrl = 'http://www.iresearch.com.cn/m/report.shtml';
|
||||||
|
|
||||||
|
const resp = await axios({
|
||||||
|
method: 'get',
|
||||||
|
url: apiUrl,
|
||||||
|
headers: {
|
||||||
|
Referer: pageUrl,
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const list = resp.data.List;
|
||||||
|
const items = await Promise.all(
|
||||||
|
list.map(async (item) => {
|
||||||
|
const other = await processReport(item, ctx);
|
||||||
|
return {
|
||||||
|
title: item.Title,
|
||||||
|
description: other,
|
||||||
|
pubDate: date(item.Uptime),
|
||||||
|
link: item.VisitUrl,
|
||||||
|
};
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: '艾瑞产业研究报告',
|
||||||
|
link: pageUrl,
|
||||||
|
description: '艾瑞产业研究报告',
|
||||||
|
item: items,
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -50,6 +50,9 @@ module.exports = (html, timeZone = -serverOffset) => {
|
|||||||
} else if (/(\d+)-(\d+)/.exec(html)) {
|
} else if (/(\d+)-(\d+)/.exec(html)) {
|
||||||
math = /(\d+)-(\d+)/.exec(html);
|
math = /(\d+)-(\d+)/.exec(html);
|
||||||
date = new Date(date.getFullYear(), parseInt(math[1]) - 1, math[2]);
|
date = new Date(date.getFullYear(), parseInt(math[1]) - 1, math[2]);
|
||||||
|
} else if (/(\d+)\/(\d+)\/(\d+) (\d+):(\d+):(\d+)/.exec(html)) {
|
||||||
|
math = /(\d+)\/(\d+)\/(\d+) (\d+):(\d+):(\d+)/.exec(html);
|
||||||
|
date = new Date(math[1], parseInt(math[2]) - 1, math[3], math[4], math[5], math[6]);
|
||||||
} else if (/(\d+):(\d+)/.exec(html)) {
|
} else if (/(\d+):(\d+)/.exec(html)) {
|
||||||
math = /(\d+):(\d+)/.exec(html);
|
math = /(\d+):(\d+)/.exec(html);
|
||||||
date = new Date(date.getFullYear(), date.getMonth(), date.getDate(), math[1], math[2]);
|
date = new Date(date.getFullYear(), date.getMonth(), date.getDate(), math[1], math[2]);
|
||||||
|
|||||||
Reference in New Issue
Block a user