From 60ad86b6f682f88ae3d75e60ae1fa9be0ac93c83 Mon Sep 17 00:00:00 2001
From: Ethan Shen <42264778+nczitzk@users.noreply.github.com>
Date: Thu, 13 Nov 2025 00:15:25 +0800
Subject: [PATCH] =?UTF-8?q?fix(route):=20=E8=89=BE=E7=91=9E=E5=92=A8?=
=?UTF-8?q?=E8=AF=A2=E7=A0=94=E7=A9=B6=E6=8A=A5=E5=91=8A=20(#20450)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* fix(route): 艾瑞咨询研究报告
* fix loop
* fix typo
* fix typo
---
lib/routes/iresearch/chart.ts | 372 ---------
lib/routes/iresearch/namespace.ts | 6 +-
lib/routes/iresearch/report.ts | 741 ++++++++++++++++--
lib/routes/iresearch/templates/chart.art | 13 -
.../iresearch/templates/description.art | 21 +
lib/routes/iresearch/templates/report.art | 5 -
lib/routes/iresearch/templates/weekly.art | 11 -
lib/routes/iresearch/weekly.ts | 145 ++--
8 files changed, 802 insertions(+), 512 deletions(-)
delete mode 100644 lib/routes/iresearch/chart.ts
delete mode 100644 lib/routes/iresearch/templates/chart.art
create mode 100644 lib/routes/iresearch/templates/description.art
delete mode 100644 lib/routes/iresearch/templates/report.art
delete mode 100644 lib/routes/iresearch/templates/weekly.art
diff --git a/lib/routes/iresearch/chart.ts b/lib/routes/iresearch/chart.ts
deleted file mode 100644
index 0f36c40b6..000000000
--- a/lib/routes/iresearch/chart.ts
+++ /dev/null
@@ -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 => {
- 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,
-};
diff --git a/lib/routes/iresearch/namespace.ts b/lib/routes/iresearch/namespace.ts
index a0fff31f3..be47b23ae 100644
--- a/lib/routes/iresearch/namespace.ts
+++ b/lib/routes/iresearch/namespace.ts
@@ -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',
};
diff --git a/lib/routes/iresearch/report.ts b/lib/routes/iresearch/report.ts
index 547cfd72e..6820cf65c 100644
--- a/lib/routes/iresearch/report.ts
+++ b/lib/routes/iresearch/report.ts
@@ -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 => {
+ 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更多行业
+
+| 名称 | 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) |
+
+
-
{{ intro }}
+{{ /if }}
+
+{{ if description }}
+ {{@ description }}
+{{ /if }}
+
+{{ if images }}
+ {{ each images image }}
+ {{ if image?.src }}
+
+
-<% } %>
-
diff --git a/lib/routes/iresearch/templates/weekly.art b/lib/routes/iresearch/templates/weekly.art
deleted file mode 100644
index ccf67d2b4..000000000
--- a/lib/routes/iresearch/templates/weekly.art
+++ /dev/null
@@ -1,11 +0,0 @@
-{{ if cover }}
-{{ content }}
-<% } %>
-{{ /if }}
\ No newline at end of file
diff --git a/lib/routes/iresearch/weekly.ts b/lib/routes/iresearch/weekly.ts
index 5fe4ba5b6..3eacd9001 100644
--- a/lib/routes/iresearch/weekly.ts
+++ b/lib/routes/iresearch/weekly.ts
@@ -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,
- };
-}