feat(route): add eastmoney gerenzhongxin 4 routes (#19791)

* feat(route): add eastmoney gerenzhongxin cfh

* feat(route): add eastmoney gerenzhongxin guba trpl

* feat(route): add eastmoney gerenzhongxin gather

* Update lib/routes/eastmoney/gerenzhongxin/cfh.ts

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/routes/eastmoney/gerenzhongxin/cfh.ts

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/routes/eastmoney/gerenzhongxin/guba.ts

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/routes/eastmoney/gerenzhongxin/cfh.ts

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/routes/eastmoney/gerenzhongxin/trpl.ts

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/routes/eastmoney/gerenzhongxin/guba.ts

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/routes/eastmoney/gerenzhongxin/trpl.ts

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/routes/eastmoney/gerenzhongxin/gather.ts

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/routes/eastmoney/gerenzhongxin/guba.ts

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/routes/eastmoney/gerenzhongxin/trpl.ts

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update use post_title instead.

* Update use blockquote instead.

* restore the abbreviated content as title. For the website is like twitter, there are only contents, no post_title.

* use blockquote to properly and semantically format the post and reply content

* Some of the posts do have a valid post_title. Now the post title has a precedence, if it is not valid, then use the abbreviated content

* fix deepscan result for INSUFFICIENT_NULL_CHECK

* fix deepscan result

---------
This commit is contained in:
AwesomeDog 2025-10-25 18:55:56 +08:00 committed by GitHub
parent 9d4efc58bb
commit ba0c820aee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 281 additions and 0 deletions

View File

@ -0,0 +1,68 @@
import { Route, ViewType } from '@/types';
import { parseDate } from '@/utils/parse-date';
import got from '@/utils/got';
import timezone from '@/utils/timezone';
export const route: Route = {
path: '/gerenzhongxin/cfh/:uid',
categories: ['finance'],
view: ViewType.Articles,
example: '/eastmoney/gerenzhongxin/cfh/2922094262312522',
parameters: { uid: '用户id,即用户主页网址末尾的数字' },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['guba.eastmoney.com'],
},
{
source: ['caifuhao.eastmoney.com'],
},
{
source: ['i.eastmoney.com/:uid'],
target: '/gerenzhongxin/cfh/:uid',
},
],
name: '个人中心长文',
maintainers: ['AwesomeDog'],
handler,
};
export async function handler(ctx) {
const uid = ctx.req.param('uid');
const url = `https://i.eastmoney.com/api/guba/postCenterList?uid=${uid}&pagenum=1&pagesize=10&type=1&filterType=1&onlyYt=0`;
const response = await got(url);
const arr = response.data.result;
// console.log(arr[0].post_user);
const nickname = arr[0].post_user.user_nickname;
const items = arr.map((item) => {
let descriptionContent = item.post_content;
if (item.post_pic_url && item.post_pic_url.length > 0) {
const imagesHTML = item.post_pic_url.map((url: string) => `<img src="${url}">`).join('');
descriptionContent += '<br>' + imagesHTML;
}
return {
title: item.post_title || `${nickname} 发布了长文: ${descriptionContent}`,
description: descriptionContent,
pubDate: timezone(parseDate(item.post_publish_time), 8),
link: `https://caifuhao.eastmoney.com/news/${item.post_source_id}`,
author: item.post_user.user_nickname,
};
});
return {
title: `${nickname} 的东财长文`,
link: `https://i.eastmoney.com/${uid}#cfh`,
image: `https://avator.eastmoney.com/qface/${uid}/360`,
item: items,
};
}

View File

@ -0,0 +1,69 @@
import { type Route, ViewType } from '@/types';
import { handler as cfhHandler } from './cfh';
import { handler as gubaHandler } from './guba';
import { handler as trplHandler } from './trpl';
export const route: Route = {
path: '/gerenzhongxin/gather/:uid',
categories: ['finance'],
view: ViewType.Articles,
example: '/eastmoney/gerenzhongxin/gather/2922094262312522',
parameters: { uid: '用户id,即用户主页网址末尾的数字' },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['guba.eastmoney.com'],
},
{
source: ['caifuhao.eastmoney.com'],
},
{
source: ['i.eastmoney.com/:uid'],
target: '/gerenzhongxin/gather/:uid',
},
],
name: '个人中心所有活动',
maintainers: ['AwesomeDog'],
handler,
};
async function handler(ctx) {
const uid = ctx.req.param('uid');
const subCtx = {
req: {
param: (key: string) => (key === 'uid' ? uid : ''),
},
};
const [cfhResult, gubaResult, trplResult] = await Promise.allSettled([cfhHandler(subCtx), gubaHandler(subCtx), trplHandler(subCtx)]);
const allItems: any[] = [];
if (cfhResult.status === 'fulfilled') {
allItems.push(...cfhResult.value.item);
}
if (gubaResult.status === 'fulfilled') {
allItems.push(...gubaResult.value.item);
}
if (trplResult.status === 'fulfilled') {
allItems.push(...trplResult.value.item);
}
allItems.sort((a, b) => b.pubDate.getTime() - a.pubDate.getTime());
const nickname = allItems[0]?.author || '用户';
return {
title: `${nickname} 的东财所有活动`,
link: `https://i.eastmoney.com/${uid}`,
image: `https://avator.eastmoney.com/qface/${uid}/360`,
item: allItems,
};
}

View File

@ -0,0 +1,68 @@
import { Route, ViewType } from '@/types';
import { parseDate } from '@/utils/parse-date';
import got from '@/utils/got';
import timezone from '@/utils/timezone';
export const route: Route = {
path: '/gerenzhongxin/guba/:uid',
categories: ['finance'],
view: ViewType.Articles,
example: '/eastmoney/gerenzhongxin/guba/2922094262312522',
parameters: { uid: '用户id,即用户主页网址末尾的数字' },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['guba.eastmoney.com'],
},
{
source: ['caifuhao.eastmoney.com'],
},
{
source: ['i.eastmoney.com/:uid'],
target: '/gerenzhongxin/guba/:uid',
},
],
name: '个人中心帖子',
maintainers: ['AwesomeDog'],
handler,
};
export async function handler(ctx) {
const uid = ctx.req.param('uid');
const url = `https://i.eastmoney.com/api/guba/postCenterList?uid=${uid}&pagenum=1&pagesize=10&type=1&filterType=2&onlyYt=0`;
const response = await got(url);
const arr = response.data.result;
const nickname = arr[0].post_user.user_nickname;
const items = arr.map((item) => {
let descriptionContent = item.post_content;
if (item.post_pic_url && item.post_pic_url.length > 0) {
const imagesHTML = item.post_pic_url.map((url: string) => `<img src="${url}">`).join('');
descriptionContent += '<br>' + imagesHTML;
}
return {
title: item.post_title || `${nickname} 发布了帖子: ${descriptionContent}`,
description: descriptionContent,
pubDate: timezone(parseDate(item.post_publish_time), 8),
link: `https://guba.eastmoney.com/news,${item.post_guba.stockbar_code},${item.post_id}.html`,
author: item.post_user.user_nickname,
};
});
return {
title: `${nickname} 的东财帖子`,
link: `https://i.eastmoney.com/${uid}#guba`,
image: `https://avator.eastmoney.com/qface/${uid}/360`,
item: items,
};
}

View File

@ -0,0 +1,76 @@
import { Route, ViewType } from '@/types';
import { parseDate } from '@/utils/parse-date';
import got from '@/utils/got';
import timezone from '@/utils/timezone';
import md5 from '@/utils/md5';
export const route: Route = {
path: '/gerenzhongxin/trpl/:uid',
categories: ['finance'],
view: ViewType.Articles,
example: '/eastmoney/gerenzhongxin/trpl/2922094262312522',
parameters: { uid: '用户id,即用户主页网址末尾的数字' },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['guba.eastmoney.com'],
},
{
source: ['caifuhao.eastmoney.com'],
},
{
source: ['i.eastmoney.com/:uid'],
target: '/gerenzhongxin/trpl/:uid',
},
],
name: '个人中心评论',
maintainers: ['AwesomeDog'],
handler,
};
export async function handler(ctx) {
const uid = ctx.req.param('uid');
const url = `https://i.eastmoney.com/api/guba/myreply?pageindex=1&uid=${uid}&checkauth=true`;
const response = await got(url);
const arr = response.data.result.list;
const nickname = arr[0].reply_user.user_nickname;
const items = arr.map((item) => {
const linkUrl = `https://guba.eastmoney.com/news,${item.reply_guba.stockbar_code},${item.source_post_id}.html#allReplyList`;
const descriptionContent = `
<p>${item.source_post_title}</p>
<hr/>
<br/>
<blockquote cite="${linkUrl}">
<p>${item.reply_text}</p>
</blockquote>
<p style="text-align:right;"> <cite>${item.reply_user.user_nickname}</cite></p>
`;
const guid: string = 'guid-' + md5(item.reply_text) + `-${item.source_post_id}`;
return {
title: item.post_title || `${nickname} 发布了评论: ${descriptionContent}`,
description: descriptionContent,
pubDate: timezone(parseDate(item.reply_publish_time), 8),
link: linkUrl,
guid,
author: item.reply_user.user_nickname,
};
});
return {
title: `${nickname} 的东财评论`,
link: `https://i.eastmoney.com/${uid}#trpl`,
image: `https://avator.eastmoney.com/qface/${uid}/360`,
item: items,
};
}