fix(route): 艾瑞咨询研究报告 (#20450)
* fix(route): 艾瑞咨询研究报告 * fix loop * fix typo * fix typo
This commit is contained in:
@@ -1,372 +0,0 @@
|
||||
import path from 'node:path';
|
||||
|
||||
import { type CheerioAPI, load } from 'cheerio';
|
||||
import { type Context } from 'hono';
|
||||
|
||||
import { type DataItem, type Route, type Data, ViewType } from '@/types';
|
||||
|
||||
import { art } from '@/utils/render';
|
||||
import ofetch from '@/utils/ofetch';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
|
||||
const categoryMap = {
|
||||
媒体文娱: 59,
|
||||
广告营销: 89,
|
||||
游戏行业: 90,
|
||||
视频媒体: 91,
|
||||
消费电商: 69,
|
||||
电子商务: 86,
|
||||
消费者洞察: 87,
|
||||
旅游行业: 88,
|
||||
汽车行业: 80,
|
||||
教育行业: 63,
|
||||
企业服务: 60,
|
||||
网络服务: 84,
|
||||
应用服务: 85,
|
||||
AI大数据: 65,
|
||||
人工智能: 83,
|
||||
物流行业: 75,
|
||||
金融行业: 70,
|
||||
支付行业: 82,
|
||||
房产行业: 68,
|
||||
医疗健康: 62,
|
||||
先进制造: 61,
|
||||
能源环保: 77,
|
||||
区块链: 76,
|
||||
其他: 81,
|
||||
};
|
||||
|
||||
export const handler = async (ctx: Context): Promise<Data> => {
|
||||
const { category: categoryName } = ctx.req.param();
|
||||
const limit: number = Number.parseInt(ctx.req.query('limit') ?? '100', 10);
|
||||
|
||||
const rootUrl: string = 'https://www.iresearch.com.cn';
|
||||
const apiUrl = new URL('api/products/getdatasapi', rootUrl).href;
|
||||
|
||||
const category = categoryMap[categoryName] || undefined;
|
||||
|
||||
const targetUrl: string = new URL(`report.shtml?type=4${category ? `&classId=${category}` : ''}`, rootUrl).href;
|
||||
|
||||
const response = await ofetch(apiUrl, {
|
||||
query: {
|
||||
rootId: 14,
|
||||
channelId: category ?? '',
|
||||
userId: '',
|
||||
lastId: '',
|
||||
pageSize: limit,
|
||||
},
|
||||
});
|
||||
|
||||
const targetResponse = await ofetch(targetUrl);
|
||||
const $: CheerioAPI = load(targetResponse);
|
||||
const language: string = $('html').prop('lang') ?? 'zh-cn';
|
||||
|
||||
const items: DataItem[] = response.List.slice(0, limit).map((item) => ({
|
||||
title: `${item.Title} - ${item.sTitle}`,
|
||||
link: new URL(`chart/detail?id=${item.Id}`, rootUrl).href,
|
||||
description: art(path.join(__dirname, 'templates/chart.art'), {
|
||||
images: [
|
||||
{
|
||||
src: item.SmallImg,
|
||||
alt: item.Title,
|
||||
},
|
||||
{
|
||||
src: item.BigImg,
|
||||
alt: item.sTitle,
|
||||
},
|
||||
],
|
||||
newsId: item.NewsId,
|
||||
}),
|
||||
author: item.Author,
|
||||
category: [...new Set([item.sTitle, item.industry, ...item.Keyword])].filter(Boolean),
|
||||
guid: `iresearch.${item.Id}`,
|
||||
pubDate: timezone(parseDate(item.Uptime), +8),
|
||||
}));
|
||||
|
||||
const author = $('title').text();
|
||||
|
||||
return {
|
||||
title: `${author} | 研究图表${category ? ` - ${categoryName}` : ''}`,
|
||||
description: $('meta[property="og:description"]').prop('content'),
|
||||
link: targetUrl,
|
||||
item: items,
|
||||
allowEmpty: true,
|
||||
author,
|
||||
language,
|
||||
id: targetUrl,
|
||||
};
|
||||
};
|
||||
|
||||
export const route: Route = {
|
||||
path: '/chart/:category?',
|
||||
name: '研究图表',
|
||||
url: 'www.iresearch.com.cn',
|
||||
maintainers: ['nczitzk'],
|
||||
handler,
|
||||
example: '/iresearch/chart',
|
||||
parameters: {
|
||||
category: '分类,见下表',
|
||||
},
|
||||
description: `
|
||||
| 媒体文娱 | 广告营销 | 游戏行业 | 视频媒体 | 消费电商 |
|
||||
| -------- | ---------- | -------- | --------- | -------- |
|
||||
| 电子商务 | 消费者洞察 | 旅游行业 | 汽车行业 | 教育行业 |
|
||||
| 企业服务 | 网络服务 | 应用服务 | AI 大数据 | 人工智能 |
|
||||
| 物流行业 | 金融行业 | 支付行业 | 房产行业 | 医疗健康 |
|
||||
| 先进制造 | 新能源 | 区块链 | 其他 | |
|
||||
`,
|
||||
categories: ['new-media'],
|
||||
features: {
|
||||
requireConfig: false,
|
||||
requirePuppeteer: false,
|
||||
antiCrawler: false,
|
||||
supportRadar: true,
|
||||
supportBT: false,
|
||||
supportPodcast: false,
|
||||
supportScihub: false,
|
||||
},
|
||||
radar: [
|
||||
{
|
||||
title: '研究图表 - 媒体文娱',
|
||||
source: ['https://www.iresearch.com.cn/report.shtml'],
|
||||
target: (_, url) => {
|
||||
const urlObj = new URL(url);
|
||||
const isChart = urlObj.searchParams.get('type') === '4';
|
||||
|
||||
return isChart ? '/iresearch/chart/媒体文娱' : '';
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '研究图表 - 广告营销',
|
||||
source: ['https://www.iresearch.com.cn/report.shtml'],
|
||||
target: (_, url) => {
|
||||
const urlObj = new URL(url);
|
||||
const isChart = urlObj.searchParams.get('type') === '4';
|
||||
|
||||
return isChart ? '/iresearch/chart/广告营销' : '';
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '研究图表 - 游戏行业',
|
||||
source: ['https://www.iresearch.com.cn/report.shtml'],
|
||||
target: (_, url) => {
|
||||
const urlObj = new URL(url);
|
||||
const isChart = urlObj.searchParams.get('type') === '4';
|
||||
|
||||
return isChart ? '/iresearch/chart/游戏行业' : '';
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '研究图表 - 视频媒体',
|
||||
source: ['https://www.iresearch.com.cn/report.shtml'],
|
||||
target: (_, url) => {
|
||||
const urlObj = new URL(url);
|
||||
const isChart = urlObj.searchParams.get('type') === '4';
|
||||
|
||||
return isChart ? '/iresearch/chart/视频媒体' : '';
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '研究图表 - 消费电商',
|
||||
source: ['https://www.iresearch.com.cn/report.shtml'],
|
||||
target: (_, url) => {
|
||||
const urlObj = new URL(url);
|
||||
const isChart = urlObj.searchParams.get('type') === '4';
|
||||
|
||||
return isChart ? '/iresearch/chart/消费电商' : '';
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '研究图表 - 电子商务',
|
||||
source: ['https://www.iresearch.com.cn/report.shtml'],
|
||||
target: (_, url) => {
|
||||
const urlObj = new URL(url);
|
||||
const isChart = urlObj.searchParams.get('type') === '4';
|
||||
|
||||
return isChart ? '/iresearch/chart/电子商务' : '';
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '研究图表 - 消费者洞察',
|
||||
source: ['https://www.iresearch.com.cn/report.shtml'],
|
||||
target: (_, url) => {
|
||||
const urlObj = new URL(url);
|
||||
const isChart = urlObj.searchParams.get('type') === '4';
|
||||
|
||||
return isChart ? '/iresearch/chart/消费者洞察' : '';
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '研究图表 - 旅游行业',
|
||||
source: ['https://www.iresearch.com.cn/report.shtml'],
|
||||
target: (_, url) => {
|
||||
const urlObj = new URL(url);
|
||||
const isChart = urlObj.searchParams.get('type') === '4';
|
||||
|
||||
return isChart ? '/iresearch/chart/旅游行业' : '';
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '研究图表 - 汽车行业',
|
||||
source: ['https://www.iresearch.com.cn/report.shtml'],
|
||||
target: (_, url) => {
|
||||
const urlObj = new URL(url);
|
||||
const isChart = urlObj.searchParams.get('type') === '4';
|
||||
|
||||
return isChart ? '/iresearch/chart/汽车行业' : '';
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '研究图表 - 教育行业',
|
||||
source: ['https://www.iresearch.com.cn/report.shtml'],
|
||||
target: (_, url) => {
|
||||
const urlObj = new URL(url);
|
||||
const isChart = urlObj.searchParams.get('type') === '4';
|
||||
|
||||
return isChart ? '/iresearch/chart/教育行业' : '';
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '研究图表 - 企业服务',
|
||||
source: ['https://www.iresearch.com.cn/report.shtml'],
|
||||
target: (_, url) => {
|
||||
const urlObj = new URL(url);
|
||||
const isChart = urlObj.searchParams.get('type') === '4';
|
||||
|
||||
return isChart ? '/iresearch/chart/企业服务' : '';
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '研究图表 - 网络服务',
|
||||
source: ['https://www.iresearch.com.cn/report.shtml'],
|
||||
target: (_, url) => {
|
||||
const urlObj = new URL(url);
|
||||
const isChart = urlObj.searchParams.get('type') === '4';
|
||||
|
||||
return isChart ? '/iresearch/chart/网络服务' : '';
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '研究图表 - 应用服务',
|
||||
source: ['https://www.iresearch.com.cn/report.shtml'],
|
||||
target: (_, url) => {
|
||||
const urlObj = new URL(url);
|
||||
const isChart = urlObj.searchParams.get('type') === '4';
|
||||
|
||||
return isChart ? '/iresearch/chart/应用服务' : '';
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '研究图表 - AI大数据',
|
||||
source: ['https://www.iresearch.com.cn/report.shtml'],
|
||||
target: (_, url) => {
|
||||
const urlObj = new URL(url);
|
||||
const isChart = urlObj.searchParams.get('type') === '4';
|
||||
|
||||
return isChart ? '/iresearch/chart/AI大数据' : '';
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '研究图表 - 人工智能',
|
||||
source: ['https://www.iresearch.com.cn/report.shtml'],
|
||||
target: (_, url) => {
|
||||
const urlObj = new URL(url);
|
||||
const isChart = urlObj.searchParams.get('type') === '4';
|
||||
|
||||
return isChart ? '/iresearch/chart/人工智能' : '';
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '研究图表 - 物流行业',
|
||||
source: ['https://www.iresearch.com.cn/report.shtml'],
|
||||
target: (_, url) => {
|
||||
const urlObj = new URL(url);
|
||||
const isChart = urlObj.searchParams.get('type') === '4';
|
||||
|
||||
return isChart ? '/iresearch/chart/物流行业' : '';
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '研究图表 - 金融行业',
|
||||
source: ['https://www.iresearch.com.cn/report.shtml'],
|
||||
target: (_, url) => {
|
||||
const urlObj = new URL(url);
|
||||
const isChart = urlObj.searchParams.get('type') === '4';
|
||||
|
||||
return isChart ? '/iresearch/chart/金融行业' : '';
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '研究图表 - 支付行业',
|
||||
source: ['https://www.iresearch.com.cn/report.shtml'],
|
||||
target: (_, url) => {
|
||||
const urlObj = new URL(url);
|
||||
const isChart = urlObj.searchParams.get('type') === '4';
|
||||
|
||||
return isChart ? '/iresearch/chart/支付行业' : '';
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '研究图表 - 房产行业',
|
||||
source: ['https://www.iresearch.com.cn/report.shtml'],
|
||||
target: (_, url) => {
|
||||
const urlObj = new URL(url);
|
||||
const isChart = urlObj.searchParams.get('type') === '4';
|
||||
|
||||
return isChart ? '/iresearch/chart/房产行业' : '';
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '研究图表 - 医疗健康',
|
||||
source: ['https://www.iresearch.com.cn/report.shtml'],
|
||||
target: (_, url) => {
|
||||
const urlObj = new URL(url);
|
||||
const isChart = urlObj.searchParams.get('type') === '4';
|
||||
|
||||
return isChart ? '/iresearch/chart/医疗健康' : '';
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '研究图表 - 先进制造',
|
||||
source: ['https://www.iresearch.com.cn/report.shtml'],
|
||||
target: (_, url) => {
|
||||
const urlObj = new URL(url);
|
||||
const isChart = urlObj.searchParams.get('type') === '4';
|
||||
|
||||
return isChart ? '/iresearch/chart/先进制造' : '';
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '研究图表 - 新能源',
|
||||
source: ['https://www.iresearch.com.cn/report.shtml'],
|
||||
target: (_, url) => {
|
||||
const urlObj = new URL(url);
|
||||
const isChart = urlObj.searchParams.get('type') === '4';
|
||||
|
||||
return isChart ? '/iresearch/chart/新能源' : '';
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '研究图表 - 区块链',
|
||||
source: ['https://www.iresearch.com.cn/report.shtml'],
|
||||
target: (_, url) => {
|
||||
const urlObj = new URL(url);
|
||||
const isChart = urlObj.searchParams.get('type') === '4';
|
||||
|
||||
return isChart ? '/iresearch/chart/区块链' : '';
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '研究图表 - 其他',
|
||||
source: ['https://www.iresearch.com.cn/report.shtml'],
|
||||
target: (_, url) => {
|
||||
const urlObj = new URL(url);
|
||||
const isChart = urlObj.searchParams.get('type') === '4';
|
||||
|
||||
return isChart ? '/iresearch/chart/其他' : '';
|
||||
},
|
||||
},
|
||||
],
|
||||
view: ViewType.Articles,
|
||||
};
|
||||
@@ -1,7 +1,9 @@
|
||||
import type { Namespace } from '@/types';
|
||||
|
||||
export const namespace: Namespace = {
|
||||
name: '艾瑞',
|
||||
url: 'www.iresearch.com.cn',
|
||||
name: '艾瑞咨询',
|
||||
url: 'iresearch.com.cn',
|
||||
categories: ['other'],
|
||||
description: '',
|
||||
lang: 'zh-CN',
|
||||
};
|
||||
|
||||
+680
-61
@@ -1,44 +1,506 @@
|
||||
import { Route } from '@/types';
|
||||
import { type Data, type DataItem, type Route, ViewType } from '@/types';
|
||||
|
||||
import cache from '@/utils/cache';
|
||||
import got from '@/utils/got';
|
||||
import { art } from '@/utils/render';
|
||||
import path from 'node:path';
|
||||
import cache from '@/utils/cache';
|
||||
import ofetch from '@/utils/ofetch';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
|
||||
function processReport(item) {
|
||||
const apiUrl = `https://www.iresearch.com.cn/api/Detail/reportM?id=${item.NewsId}&isfree=0`;
|
||||
const pageUrl = 'https://www.iresearch.com.cn/m/report.shtml';
|
||||
import { type Context } from 'hono';
|
||||
import path from 'node:path';
|
||||
|
||||
const description = cache.tryGet(apiUrl, async () => {
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: apiUrl,
|
||||
headers: {
|
||||
Referer: pageUrl,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
});
|
||||
const data = response.data.List[0];
|
||||
const types = {
|
||||
1: {
|
||||
label: '最新报告',
|
||||
value: 1,
|
||||
slug: 'products/GetReportList',
|
||||
detailSlug: 'Detail/reportM',
|
||||
imageSlug: 'rimgs',
|
||||
idKey: 'classId',
|
||||
limitKey: 'pageSize',
|
||||
detailKey: 'id',
|
||||
fixedQuery: {
|
||||
fee: 0,
|
||||
},
|
||||
detailFixedQuery: {
|
||||
isfree: 0,
|
||||
},
|
||||
},
|
||||
4: {
|
||||
label: '研究图表',
|
||||
value: 4,
|
||||
slug: 'products/getdatasapi',
|
||||
detailSlug: 'products/getonedatasapi',
|
||||
imageSlug: undefined,
|
||||
idKey: 'channelId',
|
||||
limitKey: 'pageSize',
|
||||
detailKey: 'id',
|
||||
fixedQuery: {
|
||||
rootId: 14,
|
||||
},
|
||||
detailFixedQuery: undefined,
|
||||
},
|
||||
3: {
|
||||
label: '周度市场观察',
|
||||
value: 3,
|
||||
slug: 'products/ireports',
|
||||
detailSlug: 'products/ireport',
|
||||
imageSlug: 'ireport',
|
||||
idKey: 'cid',
|
||||
limitKey: 'psize',
|
||||
detailKey: 'rid',
|
||||
fixedQuery: {
|
||||
pindex: 1,
|
||||
},
|
||||
detailFixedQuery: undefined,
|
||||
},
|
||||
2: {
|
||||
label: '热门报告',
|
||||
value: 2,
|
||||
slug: 'products/GetHotReportList',
|
||||
detailSlug: 'Detail/reportM',
|
||||
imageSlug: 'rimgs',
|
||||
idKey: 'classId',
|
||||
limitKey: 'pageSize',
|
||||
detailKey: 'id',
|
||||
fixedQuery: {
|
||||
fee: 0,
|
||||
},
|
||||
detailFixedQuery: {
|
||||
isfree: 0,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
return art(path.join(__dirname, 'templates/report.art'), {
|
||||
data,
|
||||
});
|
||||
const idOptions = [
|
||||
{
|
||||
label: '全部',
|
||||
value: '',
|
||||
},
|
||||
{
|
||||
label: '家电行业',
|
||||
value: '1',
|
||||
},
|
||||
{
|
||||
label: '服装行业',
|
||||
value: '2',
|
||||
},
|
||||
{
|
||||
label: '美妆行业',
|
||||
value: '3',
|
||||
},
|
||||
{
|
||||
label: '食品饮料行业',
|
||||
value: '4',
|
||||
},
|
||||
{
|
||||
label: '酒行业',
|
||||
value: '5',
|
||||
},
|
||||
{
|
||||
label: '媒体文娱',
|
||||
value: '59',
|
||||
},
|
||||
{
|
||||
label: '广告营销',
|
||||
value: '89',
|
||||
},
|
||||
{
|
||||
label: '游戏行业',
|
||||
value: '90',
|
||||
},
|
||||
{
|
||||
label: '视频媒体',
|
||||
value: '91',
|
||||
},
|
||||
{
|
||||
label: '消费电商',
|
||||
value: '69',
|
||||
},
|
||||
{
|
||||
label: '电子商务',
|
||||
value: '86',
|
||||
},
|
||||
{
|
||||
label: '消费者洞察',
|
||||
value: '87',
|
||||
},
|
||||
{
|
||||
label: '旅游行业',
|
||||
value: '88',
|
||||
},
|
||||
{
|
||||
label: '汽车行业',
|
||||
value: '80',
|
||||
},
|
||||
{
|
||||
label: '教育行业',
|
||||
value: '63',
|
||||
},
|
||||
{
|
||||
label: '企业服务',
|
||||
value: '60',
|
||||
},
|
||||
{
|
||||
label: '网络服务',
|
||||
value: '84',
|
||||
},
|
||||
{
|
||||
label: '应用服务',
|
||||
value: '85',
|
||||
},
|
||||
{
|
||||
label: 'AI大数据',
|
||||
value: '65',
|
||||
},
|
||||
{
|
||||
label: '人工智能',
|
||||
value: '83',
|
||||
},
|
||||
{
|
||||
label: '物流行业',
|
||||
value: '75',
|
||||
},
|
||||
{
|
||||
label: '金融行业',
|
||||
value: '70',
|
||||
},
|
||||
{
|
||||
label: '支付行业',
|
||||
value: '82',
|
||||
},
|
||||
{
|
||||
label: '房产行业',
|
||||
value: '68',
|
||||
},
|
||||
{
|
||||
label: '医疗健康',
|
||||
value: '62',
|
||||
},
|
||||
{
|
||||
label: '先进制造',
|
||||
value: '61',
|
||||
},
|
||||
{
|
||||
label: '能源环保',
|
||||
value: '77',
|
||||
},
|
||||
{
|
||||
label: '区块链',
|
||||
value: '76',
|
||||
},
|
||||
{
|
||||
label: '其他',
|
||||
value: '81',
|
||||
},
|
||||
];
|
||||
|
||||
const defaultType = 1;
|
||||
const siteTitle = '艾瑞咨询';
|
||||
|
||||
export const handler = async (ctx: Context): Promise<Data> => {
|
||||
const { type: paramType = defaultType, id: paramId = '' } = ctx.req.param();
|
||||
const limit: number = Number.parseInt(ctx.req.query('limit') ?? '50', 10);
|
||||
|
||||
const typeObj = types?.[paramType] ?? Object.values(types).find((obj) => obj.label === paramType || obj.value === paramType);
|
||||
if (!typeObj) {
|
||||
throw new Error(`Invalid type: ${paramType}. Please refer to [the documentation](https://docs.rsshub.app/routes/other#${siteTitle}) for valid types.`);
|
||||
}
|
||||
|
||||
const idObj = idOptions.find((option) => option.label === paramId || option.value === paramId);
|
||||
|
||||
const type: number = typeObj.value;
|
||||
const id: string | undefined = idObj ? String(idObj.value) : undefined;
|
||||
|
||||
const baseUrl: string = 'https://www.iresearch.com.cn';
|
||||
const imageBaseUrl: string = 'https://pic.iresearch.cn';
|
||||
const targetUrl: string = new URL(`report.shtml?type=${type}${id ? `&classId=${id}` : ''}`, baseUrl).href;
|
||||
const apiUrl: string = new URL(`api/${typeObj.slug}`, baseUrl).href;
|
||||
const apiDetailUrl: string = new URL(`api/${typeObj.detailSlug}`, baseUrl).href;
|
||||
|
||||
const response = await ofetch(apiUrl, {
|
||||
query: {
|
||||
...(id
|
||||
? {
|
||||
[typeObj.idKey]: id,
|
||||
}
|
||||
: {}),
|
||||
[typeObj.limitKey]: limit,
|
||||
...typeObj.fixedQuery,
|
||||
},
|
||||
});
|
||||
|
||||
return description;
|
||||
}
|
||||
let items: DataItem[] = [];
|
||||
|
||||
items = response.List.slice(0, limit).map((item): DataItem => {
|
||||
const title: string =
|
||||
item.reportname ??
|
||||
(() => {
|
||||
if (item.Title) {
|
||||
const suffix: string = item.sTitle && item.sTitle !== item.Title ? ` - ${item.sTitle}` : '';
|
||||
return `${item.Title}${suffix}`;
|
||||
}
|
||||
|
||||
return item.sTitle ?? item.Content;
|
||||
})();
|
||||
|
||||
const images: string[] = [item.BigImg, item.SmallImg, item.reportpic].filter(Boolean) as string[];
|
||||
const description: string | undefined = art(path.join(__dirname, 'templates/description.art'), {
|
||||
images: images.map((src) => ({
|
||||
src,
|
||||
alt: title,
|
||||
})),
|
||||
intro: item.Content,
|
||||
});
|
||||
|
||||
const pubDate: number | string = item.Uptime ?? item.addtime;
|
||||
const linkUrl: string | undefined = item.VisitUrl;
|
||||
const categories: string[] = [...new Set([item.sTitle, item.industry, item.classname, ...(item.Keyword ?? [])])].filter(Boolean);
|
||||
const authors: DataItem['author'] = item.Author;
|
||||
const guid: string = item.Id ? `iresearch-${item.Id}` : item.id ? `iresearch-ireport.${item.id}` : '';
|
||||
const image: string | undefined = images?.[0] ?? undefined;
|
||||
const updated: number | string = pubDate;
|
||||
|
||||
let processedItem: DataItem = {
|
||||
title,
|
||||
description,
|
||||
pubDate: pubDate ? timezone(parseDate(pubDate), +8) : undefined,
|
||||
link: item.id ? new URL(`report/detail?id=${item.id}`, baseUrl).href : (linkUrl ?? (item.Id ? new URL(`chart/detail?id=${item.id}`, baseUrl).href : undefined)),
|
||||
category: categories,
|
||||
author: authors,
|
||||
guid,
|
||||
id: guid,
|
||||
content: {
|
||||
html: description,
|
||||
text: description,
|
||||
},
|
||||
image,
|
||||
banner: image,
|
||||
updated: updated ? timezone(parseDate(updated), +8) : undefined,
|
||||
detailId: item.id ?? (linkUrl ? item.NewsId : item.Id),
|
||||
};
|
||||
|
||||
const medias: Record<string, Record<string, string>> = (() => {
|
||||
const result: Record<string, Record<string, string>> = {};
|
||||
const medium: string = 'image';
|
||||
let count: number = 0;
|
||||
|
||||
for (const media of images) {
|
||||
const url: string | undefined = media;
|
||||
|
||||
if (!url) {
|
||||
continue;
|
||||
}
|
||||
|
||||
count += 1;
|
||||
const key: string = `${medium}${count}`;
|
||||
|
||||
result[key] = {
|
||||
url,
|
||||
medium,
|
||||
title,
|
||||
description: title,
|
||||
thumbnail: url,
|
||||
};
|
||||
}
|
||||
|
||||
return result;
|
||||
})();
|
||||
|
||||
processedItem = {
|
||||
...processedItem,
|
||||
media: medias,
|
||||
};
|
||||
|
||||
return processedItem;
|
||||
});
|
||||
|
||||
items = await Promise.all(
|
||||
items.map((item) => {
|
||||
if (!item.link || (item.guid ? /chart\.\d+$/.test(item.guid) : false)) {
|
||||
delete item.detailId;
|
||||
return item;
|
||||
}
|
||||
|
||||
return cache.tryGet(item.link, async (): Promise<DataItem> => {
|
||||
const detailResponse = await ofetch(apiDetailUrl, {
|
||||
query: {
|
||||
[typeObj.detailKey]: item.detailId,
|
||||
...typeObj.detailFixedQuery,
|
||||
},
|
||||
});
|
||||
const data = detailResponse.List?.[0] ?? detailResponse.List ?? undefined;
|
||||
|
||||
if (!data) {
|
||||
delete item.detailId;
|
||||
return item;
|
||||
}
|
||||
|
||||
const title: string = data.Title ?? data.reportname ?? item.title;
|
||||
const images: string[] = [
|
||||
data.BigImg,
|
||||
data.SmallImg,
|
||||
data.Topic,
|
||||
data.reportpic,
|
||||
...Array.from(
|
||||
{
|
||||
length: Number.parseInt(data.PagesCount ?? data.pagesCount, 10),
|
||||
},
|
||||
(_, index) => `${imageBaseUrl}/${typeObj.imageSlug}/${item.detailId}/${index + 1}.jpg`
|
||||
),
|
||||
].filter(Boolean) as string[];
|
||||
const description: string | undefined = art(path.join(__dirname, 'templates/description.art'), {
|
||||
images: images.map((src) => ({
|
||||
src,
|
||||
alt: title,
|
||||
})),
|
||||
description: data.Content,
|
||||
});
|
||||
const pubDate: number | string = data.Uptime;
|
||||
const categories: string[] = [...new Set([...(item.category ?? []), data.industry, ...(data.Keyword ?? []), ...(data.keywords?.split(/,/) ?? [])])].filter(Boolean);
|
||||
const image: string | undefined = images?.[0] ?? undefined;
|
||||
const updated: number | string = pubDate;
|
||||
|
||||
let processedItem: DataItem = {
|
||||
title,
|
||||
description,
|
||||
pubDate: pubDate ? timezone(parseDate(pubDate), +8) : undefined,
|
||||
category: categories,
|
||||
content: {
|
||||
html: description,
|
||||
text: description,
|
||||
},
|
||||
image,
|
||||
banner: image,
|
||||
updated: updated ? timezone(parseDate(updated), +8) : undefined,
|
||||
};
|
||||
|
||||
const medias: Record<string, Record<string, string>> = (() => {
|
||||
const result: Record<string, Record<string, string>> = {};
|
||||
const medium: string = 'image';
|
||||
let count: number = 0;
|
||||
|
||||
for (const media of images) {
|
||||
const url: string | undefined = media;
|
||||
|
||||
if (!url) {
|
||||
continue;
|
||||
}
|
||||
|
||||
count += 1;
|
||||
const key: string = `${medium}${count}`;
|
||||
|
||||
result[key] = {
|
||||
url,
|
||||
medium,
|
||||
title,
|
||||
description: title,
|
||||
thumbnail: url,
|
||||
};
|
||||
}
|
||||
|
||||
return result;
|
||||
})();
|
||||
|
||||
processedItem = {
|
||||
...processedItem,
|
||||
media: medias,
|
||||
};
|
||||
|
||||
delete item.detailId;
|
||||
|
||||
return {
|
||||
...item,
|
||||
...processedItem,
|
||||
};
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
return {
|
||||
title: `${siteTitle}${typeObj.label ? ` - ${typeObj.label}` : ''}${idObj && idObj.label ? ` - ${idObj.label}` : ''}`,
|
||||
description: siteTitle,
|
||||
link: targetUrl,
|
||||
item: items,
|
||||
allowEmpty: true,
|
||||
author: siteTitle,
|
||||
id: targetUrl,
|
||||
};
|
||||
};
|
||||
|
||||
export const route: Route = {
|
||||
path: '/report',
|
||||
categories: ['other'],
|
||||
path: '/report/:type?/:id?',
|
||||
name: '研究报告',
|
||||
url: 'www.iresearch.com.cn',
|
||||
maintainers: ['brilon', 'Fatpandac', 'nczitzk'],
|
||||
handler,
|
||||
example: '/iresearch/report',
|
||||
parameters: {},
|
||||
parameters: {
|
||||
type: {
|
||||
description: '分类,默认为 `1`,即最新报告,可在对应分类页 URL 中找到',
|
||||
options: Object.values(types).map((item) => ({
|
||||
label: item.label,
|
||||
value: String(item.value),
|
||||
})),
|
||||
},
|
||||
id: {
|
||||
description: '行业 ID,默认为全部,即全部行业,可在对应行业页 URL 中找到',
|
||||
options: idOptions,
|
||||
},
|
||||
},
|
||||
description: `:::tip
|
||||
订阅 [电子商务最新报告](https://www.iresearch.com.cn/report.shtml?type=1&classId=86),其源网址为 \`https://www.iresearch.com.cn/report.shtml?type=1&classId=86\`,请参考该 URL 指定部分构成参数,此时路由为 [\`/iresearch/report/最新报告/电子商务\`](https://rsshub.app/iresearch/report/最新报告/电子商务) 或 [\`/iresearch/report/1/86\`](https://rsshub.app/iresearch/report/1/86)。
|
||||
:::
|
||||
|
||||
#### 分类
|
||||
|
||||
| [最新报告](https://www.iresearch.com.cn/report.shtml?type=1) | [研究图表](https://www.iresearch.com.cn/report.shtml?type=4) | [周度市场观察](https://www.iresearch.com.cn/report.shtml?type=3) | [热门报告](https://www.iresearch.com.cn/report.shtml?type=2) |
|
||||
| ------------------------------------------------------------ | ------------------------------------------------------------ | ---------------------------------------------------------------- | ------------------------------------------------------------ |
|
||||
| [1](https://rsshub.app/iresearch/report/1) | [4](https://rsshub.app/iresearch/report/4) | [3](https://rsshub.app/iresearch/report/3) | [2](https://rsshub.app/iresearch/report/2) |
|
||||
|
||||
<details>
|
||||
<summary>更多行业</summary>
|
||||
|
||||
| 名称 | ID |
|
||||
| -------------------------------------------------------------------------- | ---------------------------------------------- |
|
||||
| [家电行业](https://www.iresearch.com.cn/report.shtml?type=3&classId=1) | [1](https://rsshub.app/iresearch/report/3/1) |
|
||||
| [服装行业](https://www.iresearch.com.cn/report.shtml?type=3&classId=2) | [2](https://rsshub.app/iresearch/report/3/2) |
|
||||
| [美妆行业](https://www.iresearch.com.cn/report.shtml?type=3&classId=3) | [3](https://rsshub.app/iresearch/report/3/3) |
|
||||
| [食品饮料行业](https://www.iresearch.com.cn/report.shtml?type=3&classId=4) | [4](https://rsshub.app/iresearch/report/3/4) |
|
||||
| [酒行业](https://www.iresearch.com.cn/report.shtml?type=3&classId=5) | [5](https://rsshub.app/iresearch/report/3/5) |
|
||||
| [媒体文娱](https://www.iresearch.com.cn/report.shtml?classId=59) | [59](https://rsshub.app/iresearch/report/1/59) |
|
||||
| [广告营销](https://www.iresearch.com.cn/report.shtml?classId=89) | [89](https://rsshub.app/iresearch/report/1/89) |
|
||||
| [游戏行业](https://www.iresearch.com.cn/report.shtml?classId=90) | [90](https://rsshub.app/iresearch/report/1/90) |
|
||||
| [视频媒体](https://www.iresearch.com.cn/report.shtml?classId=91) | [91](https://rsshub.app/iresearch/report/1/91) |
|
||||
| [消费电商](https://www.iresearch.com.cn/report.shtml?classId=69) | [69](https://rsshub.app/iresearch/report/1/69) |
|
||||
| [电子商务](https://www.iresearch.com.cn/report.shtml?classId=86) | [86](https://rsshub.app/iresearch/report/1/86) |
|
||||
| [消费者洞察](https://www.iresearch.com.cn/report.shtml?classId=87) | [87](https://rsshub.app/iresearch/report/1/87) |
|
||||
| [旅游行业](https://www.iresearch.com.cn/report.shtml?classId=88) | [88](https://rsshub.app/iresearch/report/1/88) |
|
||||
| [汽车行业](https://www.iresearch.com.cn/report.shtml?classId=80) | [80](https://rsshub.app/iresearch/report/1/80) |
|
||||
| [教育行业](https://www.iresearch.com.cn/report.shtml?classId=63) | [63](https://rsshub.app/iresearch/report/1/63) |
|
||||
| [企业服务](https://www.iresearch.com.cn/report.shtml?classId=60) | [60](https://rsshub.app/iresearch/report/1/60) |
|
||||
| [网络服务](https://www.iresearch.com.cn/report.shtml?classId=84) | [84](https://rsshub.app/iresearch/report/1/84) |
|
||||
| [应用服务](https://www.iresearch.com.cn/report.shtml?classId=85) | [85](https://rsshub.app/iresearch/report/1/85) |
|
||||
| [AI 大数据](https://www.iresearch.com.cn/report.shtml?classId=65) | [65](https://rsshub.app/iresearch/report/1/65) |
|
||||
| [人工智能](https://www.iresearch.com.cn/report.shtml?classId=83) | [83](https://rsshub.app/iresearch/report/1/83) |
|
||||
| [物流行业](https://www.iresearch.com.cn/report.shtml?classId=75) | [75](https://rsshub.app/iresearch/report/1/75) |
|
||||
| [金融行业](https://www.iresearch.com.cn/report.shtml?classId=70) | [70](https://rsshub.app/iresearch/report/1/70) |
|
||||
| [支付行业](https://www.iresearch.com.cn/report.shtml?classId=82) | [82](https://rsshub.app/iresearch/report/1/82) |
|
||||
| [房产行业](https://www.iresearch.com.cn/report.shtml?classId=68) | [68](https://rsshub.app/iresearch/report/1/68) |
|
||||
| [医疗健康](https://www.iresearch.com.cn/report.shtml?classId=62) | [62](https://rsshub.app/iresearch/report/1/62) |
|
||||
| [先进制造](https://www.iresearch.com.cn/report.shtml?classId=61) | [61](https://rsshub.app/iresearch/report/1/61) |
|
||||
| [能源环保](https://www.iresearch.com.cn/report.shtml?classId=77) | [77](https://rsshub.app/iresearch/report/1/77) |
|
||||
| [区块链](https://www.iresearch.com.cn/report.shtml?classId=76) | [76](https://rsshub.app/iresearch/report/1/76) |
|
||||
| [其他](https://www.iresearch.com.cn/report.shtml?classId=81) | [81](https://rsshub.app/iresearch/report/1/81) |
|
||||
|
||||
</details>
|
||||
`,
|
||||
categories: ['other'],
|
||||
features: {
|
||||
requireConfig: false,
|
||||
requirePuppeteer: false,
|
||||
antiCrawler: false,
|
||||
supportRadar: true,
|
||||
supportBT: false,
|
||||
supportPodcast: false,
|
||||
supportScihub: false,
|
||||
@@ -46,42 +508,199 @@ export const route: Route = {
|
||||
radar: [
|
||||
{
|
||||
source: ['www.iresearch.com.cn/report.shtml'],
|
||||
target: (_, url) => {
|
||||
const urlObj: URL = new URL(url);
|
||||
const type: string | undefined = urlObj.searchParams.get('type') ?? undefined;
|
||||
const id: string | undefined = urlObj.searchParams.get('classId') ?? urlObj.searchParams.get('channelId') ?? urlObj.searchParams.get('cid') ?? undefined;
|
||||
|
||||
return `/iresearch/report${type ? `/${type}${id ? `/${id}` : ''}` : ''}`;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '最新报告',
|
||||
source: ['www.iresearch.com.cn/report.shtml'],
|
||||
target: (_, url) => {
|
||||
const urlObj: URL = new URL(url);
|
||||
const id: string | undefined = urlObj.searchParams.get('classId') ?? urlObj.searchParams.get('channelId') ?? urlObj.searchParams.get('cid') ?? undefined;
|
||||
|
||||
return `/iresearch/report/1${id ? `/${id}` : ''}`;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '研究图表',
|
||||
source: ['www.iresearch.com.cn/report.shtml'],
|
||||
target: (_, url) => {
|
||||
const urlObj: URL = new URL(url);
|
||||
const id: string | undefined = urlObj.searchParams.get('classId') ?? urlObj.searchParams.get('channelId') ?? urlObj.searchParams.get('cid') ?? undefined;
|
||||
|
||||
return `/iresearch/report/4${id ? `/${id}` : ''}`;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '周度市场观察',
|
||||
source: ['www.iresearch.com.cn/report.shtml'],
|
||||
target: (_, url) => {
|
||||
const urlObj: URL = new URL(url);
|
||||
const id: string | undefined = urlObj.searchParams.get('classId') ?? urlObj.searchParams.get('channelId') ?? urlObj.searchParams.get('cid') ?? undefined;
|
||||
|
||||
return `/iresearch/report/3${id ? `/${id}` : ''}`;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '热门报告',
|
||||
source: ['www.iresearch.com.cn/report.shtml'],
|
||||
target: (_, url) => {
|
||||
const urlObj: URL = new URL(url);
|
||||
const id: string | undefined = urlObj.searchParams.get('classId') ?? urlObj.searchParams.get('channelId') ?? urlObj.searchParams.get('cid') ?? undefined;
|
||||
|
||||
return `/iresearch/report/2${id ? `/${id}` : ''}`;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '周度市场观察 - 家电行业',
|
||||
source: ['www.iresearch.com.cn/report.shtml'],
|
||||
target: '/report/3/1',
|
||||
},
|
||||
{
|
||||
title: '周度市场观察 - 服装行业',
|
||||
source: ['www.iresearch.com.cn/report.shtml'],
|
||||
target: '/report/3/2',
|
||||
},
|
||||
{
|
||||
title: '周度市场观察 - 美妆行业',
|
||||
source: ['www.iresearch.com.cn/report.shtml'],
|
||||
target: '/report/3/3',
|
||||
},
|
||||
{
|
||||
title: '周度市场观察 - 食品饮料行业',
|
||||
source: ['www.iresearch.com.cn/report.shtml'],
|
||||
target: '/report/3/4',
|
||||
},
|
||||
{
|
||||
title: '周度市场观察 - 酒行业',
|
||||
source: ['www.iresearch.com.cn/report.shtml'],
|
||||
target: '/report/3/5',
|
||||
},
|
||||
{
|
||||
title: '最新报告 - 媒体文娱',
|
||||
source: ['www.iresearch.com.cn/report.shtml'],
|
||||
target: '/report/1/59',
|
||||
},
|
||||
{
|
||||
title: '最新报告 - 广告营销',
|
||||
source: ['www.iresearch.com.cn/report.shtml'],
|
||||
target: '/report/1/89',
|
||||
},
|
||||
{
|
||||
title: '最新报告 - 游戏行业',
|
||||
source: ['www.iresearch.com.cn/report.shtml'],
|
||||
target: '/report/1/90',
|
||||
},
|
||||
{
|
||||
title: '最新报告 - 视频媒体',
|
||||
source: ['www.iresearch.com.cn/report.shtml'],
|
||||
target: '/report/1/91',
|
||||
},
|
||||
{
|
||||
title: '最新报告 - 消费电商',
|
||||
source: ['www.iresearch.com.cn/report.shtml'],
|
||||
target: '/report/1/69',
|
||||
},
|
||||
{
|
||||
title: '最新报告 - 电子商务',
|
||||
source: ['www.iresearch.com.cn/report.shtml'],
|
||||
target: '/report/1/86',
|
||||
},
|
||||
{
|
||||
title: '最新报告 - 消费者洞察',
|
||||
source: ['www.iresearch.com.cn/report.shtml'],
|
||||
target: '/report/1/87',
|
||||
},
|
||||
{
|
||||
title: '最新报告 - 旅游行业',
|
||||
source: ['www.iresearch.com.cn/report.shtml'],
|
||||
target: '/report/1/88',
|
||||
},
|
||||
{
|
||||
title: '最新报告 - 汽车行业',
|
||||
source: ['www.iresearch.com.cn/report.shtml'],
|
||||
target: '/report/1/80',
|
||||
},
|
||||
{
|
||||
title: '最新报告 - 教育行业',
|
||||
source: ['www.iresearch.com.cn/report.shtml'],
|
||||
target: '/report/1/63',
|
||||
},
|
||||
{
|
||||
title: '最新报告 - 企业服务',
|
||||
source: ['www.iresearch.com.cn/report.shtml'],
|
||||
target: '/report/1/60',
|
||||
},
|
||||
{
|
||||
title: '最新报告 - 网络服务',
|
||||
source: ['www.iresearch.com.cn/report.shtml'],
|
||||
target: '/report/1/84',
|
||||
},
|
||||
{
|
||||
title: '最新报告 - 应用服务',
|
||||
source: ['www.iresearch.com.cn/report.shtml'],
|
||||
target: '/report/1/85',
|
||||
},
|
||||
{
|
||||
title: '最新报告 - AI 大数据',
|
||||
source: ['www.iresearch.com.cn/report.shtml'],
|
||||
target: '/report/1/65',
|
||||
},
|
||||
{
|
||||
title: '最新报告 - 人工智能',
|
||||
source: ['www.iresearch.com.cn/report.shtml'],
|
||||
target: '/report/1/83',
|
||||
},
|
||||
{
|
||||
title: '最新报告 - 物流行业',
|
||||
source: ['www.iresearch.com.cn/report.shtml'],
|
||||
target: '/report/1/75',
|
||||
},
|
||||
{
|
||||
title: '最新报告 - 金融行业',
|
||||
source: ['www.iresearch.com.cn/report.shtml'],
|
||||
target: '/report/1/70',
|
||||
},
|
||||
{
|
||||
title: '最新报告 - 支付行业',
|
||||
source: ['www.iresearch.com.cn/report.shtml'],
|
||||
target: '/report/1/82',
|
||||
},
|
||||
{
|
||||
title: '最新报告 - 房产行业',
|
||||
source: ['www.iresearch.com.cn/report.shtml'],
|
||||
target: '/report/1/68',
|
||||
},
|
||||
{
|
||||
title: '最新报告 - 医疗健康',
|
||||
source: ['www.iresearch.com.cn/report.shtml'],
|
||||
target: '/report/1/62',
|
||||
},
|
||||
{
|
||||
title: '最新报告 - 先进制造',
|
||||
source: ['www.iresearch.com.cn/report.shtml'],
|
||||
target: '/report/1/61',
|
||||
},
|
||||
{
|
||||
title: '最新报告 - 能源环保',
|
||||
source: ['www.iresearch.com.cn/report.shtml'],
|
||||
target: '/report/1/77',
|
||||
},
|
||||
{
|
||||
title: '最新报告 - 区块链',
|
||||
source: ['www.iresearch.com.cn/report.shtml'],
|
||||
target: '/report/1/76',
|
||||
},
|
||||
{
|
||||
title: '最新报告 - 其他',
|
||||
source: ['www.iresearch.com.cn/report.shtml'],
|
||||
target: '/report/1/81',
|
||||
},
|
||||
],
|
||||
name: '产业研究报告',
|
||||
maintainers: ['brilon', 'Fatpandac'],
|
||||
handler,
|
||||
url: 'www.iresearch.com.cn/report.shtml',
|
||||
view: ViewType.Articles,
|
||||
};
|
||||
|
||||
async function handler(ctx) {
|
||||
const limit = Number.isNaN(Number.parseInt(ctx.req.query('limit'))) ? 20 : Number.parseInt(ctx.req.query('limit'));
|
||||
const apiUrl = `https://www.iresearch.com.cn/api/products/GetReportList?fee=0&date=&lastId=&pageSize=${limit}`;
|
||||
const pageUrl = 'https://www.iresearch.com.cn/m/report.shtml';
|
||||
|
||||
const resp = await got({
|
||||
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) => ({
|
||||
title: item.Title,
|
||||
description: await processReport(item),
|
||||
pubDate: timezone(parseDate(item.Uptime), +8),
|
||||
link: item.VisitUrl,
|
||||
}))
|
||||
);
|
||||
|
||||
return {
|
||||
title: '艾瑞产业研究报告',
|
||||
link: pageUrl,
|
||||
description: '艾瑞产业研究报告',
|
||||
item: items,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
{{ if newsId }}
|
||||
<a href="/Detail/report?id={{ newsId }}&isfree=0" target="_blank">查看报告</a>
|
||||
{{ /if }}
|
||||
|
||||
{{ if images }}
|
||||
{{ each images image }}
|
||||
{{ if image?.src }}
|
||||
<figure>
|
||||
<img src="{{ image.src }}">
|
||||
</figure>
|
||||
{{ /if }}
|
||||
{{ /each }}
|
||||
{{ /if }}
|
||||
@@ -0,0 +1,21 @@
|
||||
{{ if intro }}
|
||||
<blockquote>{{ intro }}</blockquote>
|
||||
{{ /if }}
|
||||
|
||||
{{ if description }}
|
||||
{{@ description }}
|
||||
{{ /if }}
|
||||
|
||||
{{ if images }}
|
||||
{{ each images image }}
|
||||
{{ if image?.src }}
|
||||
<figure>
|
||||
<img
|
||||
{{ if image.alt }}
|
||||
alt="{{ image.alt }}"
|
||||
{{ /if }}
|
||||
src="{{ image.src }}">
|
||||
</figure>
|
||||
{{ /if }}
|
||||
{{ /each }}
|
||||
{{ /if }}
|
||||
@@ -1,5 +0,0 @@
|
||||
{{@ data.Content }}
|
||||
<% for (let i = 1; i <= data.PagesCount; i++){ %>
|
||||
<img src="http://pic.iresearch.cn/rimgs/{{ data.id }}/{{ i }}.jpg" rel="no-referrer">
|
||||
<% } %>
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
{{ if cover }}
|
||||
<img src="{{ cover }}"
|
||||
{{ /if }}
|
||||
{{ if content }}
|
||||
<p>{{ content }}</p>
|
||||
{{ /if }}
|
||||
{{ if pages }}
|
||||
<% for (let i = 1; i <= pages; i++){ %>
|
||||
<img src="https://pic.iresearch.cn/ireport/{{ id }}/{{ i }}.jpg">
|
||||
<% } %>
|
||||
{{ /if }}
|
||||
@@ -1,61 +1,110 @@
|
||||
import { Route } from '@/types';
|
||||
import { type Data, type Route, ViewType } from '@/types';
|
||||
|
||||
import got from '@/utils/got';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import { art } from '@/utils/render';
|
||||
import path from 'node:path';
|
||||
import { type Context } from 'hono';
|
||||
|
||||
export const handler = (ctx: Context): Data | undefined => {
|
||||
const { id } = ctx.req.param();
|
||||
const limit: number = Number.parseInt(ctx.req.query('limit') ?? '20', 10);
|
||||
|
||||
ctx.set('redirect', `/iresearch/report/3${id ? `/${id}` : ''}?limit=${limit}`);
|
||||
return;
|
||||
};
|
||||
|
||||
export const route: Route = {
|
||||
path: '/weekly/:category?',
|
||||
categories: ['other'],
|
||||
path: '/weekly/:id?',
|
||||
name: '周度市场观察',
|
||||
url: 'www.iresearch.com.cn',
|
||||
maintainers: ['nczitzk'],
|
||||
handler,
|
||||
example: '/iresearch/weekly',
|
||||
parameters: { category: '分类,见下表,默认为全部' },
|
||||
parameters: {
|
||||
id: {
|
||||
description: '行业 ID,默认为全部,即全部行业,可在对应行业页 URL 中找到',
|
||||
options: [
|
||||
{
|
||||
label: '全部',
|
||||
value: '',
|
||||
},
|
||||
{
|
||||
label: '家电行业',
|
||||
value: '1',
|
||||
},
|
||||
{
|
||||
label: '服装行业',
|
||||
value: '2',
|
||||
},
|
||||
{
|
||||
label: '美妆行业',
|
||||
value: '3',
|
||||
},
|
||||
{
|
||||
label: '食品饮料行业',
|
||||
value: '4',
|
||||
},
|
||||
{
|
||||
label: '酒行业',
|
||||
value: '5',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
description: `:::tip
|
||||
订阅 [家电行业](https://www.iresearch.com.cn/report.shtml?type=3&classId=1),其源网址为 \`https://www.iresearch.com.cn/report.shtml?type=3&classId=1\`,请参考该 URL 指定部分构成参数,此时路由为 [\`/iresearch/weekly/家电行业\`](https://rsshub.app/iresearch/weekly/家电行业) 或 [\`/iresearch/weekly/1\`](https://rsshub.app/iresearch/weekly/1)。
|
||||
:::
|
||||
|
||||
| 名称 | ID |
|
||||
| -------------------------------------------------------------------------- | -------------------------------------------- |
|
||||
| [家电行业](https://www.iresearch.com.cn/report.shtml?type=3&classId=1) | [1](https://rsshub.app/iresearch/report/3/1) |
|
||||
| [服装行业](https://www.iresearch.com.cn/report.shtml?type=3&classId=2) | [2](https://rsshub.app/iresearch/report/3/2) |
|
||||
| [美妆行业](https://www.iresearch.com.cn/report.shtml?type=3&classId=3) | [3](https://rsshub.app/iresearch/report/3/3) |
|
||||
| [食品饮料行业](https://www.iresearch.com.cn/report.shtml?type=3&classId=4) | [4](https://rsshub.app/iresearch/report/3/4) |
|
||||
| [酒行业](https://www.iresearch.com.cn/report.shtml?type=3&classId=5) | [5](https://rsshub.app/iresearch/report/3/5) |
|
||||
`,
|
||||
categories: ['other'],
|
||||
features: {
|
||||
requireConfig: false,
|
||||
requirePuppeteer: false,
|
||||
antiCrawler: false,
|
||||
supportRadar: true,
|
||||
supportBT: false,
|
||||
supportPodcast: false,
|
||||
supportScihub: false,
|
||||
},
|
||||
name: '周度市场观察',
|
||||
maintainers: ['nczitzk'],
|
||||
handler,
|
||||
description: `| 家电行业 | 服装行业 | 美妆行业 | 食品饮料行业 |
|
||||
| -------- | -------- | -------- | ------------ |`,
|
||||
radar: [
|
||||
{
|
||||
source: ['www.iresearch.com.cn/report.shtml'],
|
||||
target: (_, url) => {
|
||||
const urlObj: URL = new URL(url);
|
||||
const id: string | undefined = urlObj.searchParams.get('classId') ?? urlObj.searchParams.get('channelId') ?? urlObj.searchParams.get('cid') ?? undefined;
|
||||
|
||||
return `/iresearch/weekly${id ? `/${id}` : ''}`;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '家电行业',
|
||||
source: ['www.iresearch.com.cn/report.shtml'],
|
||||
target: '/weekly/1',
|
||||
},
|
||||
{
|
||||
title: '服装行业',
|
||||
source: ['www.iresearch.com.cn/report.shtml'],
|
||||
target: '/weekly/2',
|
||||
},
|
||||
{
|
||||
title: '美妆行业',
|
||||
source: ['www.iresearch.com.cn/report.shtml'],
|
||||
target: '/weekly/3',
|
||||
},
|
||||
{
|
||||
title: '食品饮料行业',
|
||||
source: ['www.iresearch.com.cn/report.shtml'],
|
||||
target: '/weekly/4',
|
||||
},
|
||||
{
|
||||
title: '酒行业',
|
||||
source: ['www.iresearch.com.cn/report.shtml'],
|
||||
target: '/weekly/5',
|
||||
},
|
||||
],
|
||||
view: ViewType.Articles,
|
||||
};
|
||||
|
||||
async function handler(ctx) {
|
||||
const category = ctx.req.param('category') ?? '';
|
||||
|
||||
const rootUrl = 'https://www.iresearch.com.cn';
|
||||
const currentUrl = `${rootUrl}/report?type=3`;
|
||||
const apiUrl = `${rootUrl}/api/json/report/ireport.json`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: apiUrl,
|
||||
});
|
||||
|
||||
const items = JSON.parse(response.data.slice(1))
|
||||
.filter((item) => (category ? item.classname === category : true))
|
||||
.slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 200)
|
||||
.map((item) => ({
|
||||
title: item.reportname,
|
||||
pubDate: parseDate(item.addtime),
|
||||
link: `${rootUrl}/report/detail?id=${item.id}`,
|
||||
category: [item.classname, ...item.keywords.split(',')],
|
||||
description: art(path.join(__dirname, 'templates/weekly.art'), {
|
||||
id: item.id,
|
||||
cover: item.reportpic,
|
||||
content: item.shortcoutent,
|
||||
pages: item.PagesCount,
|
||||
}),
|
||||
}));
|
||||
|
||||
return {
|
||||
title: '艾瑞咨询 - 周度市场观察',
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user