From fb1d38590d4bc1ef7bce691c627030bb55a12b70 Mon Sep 17 00:00:00 2001 From: Tony Date: Wed, 6 Mar 2024 22:04:41 +0800 Subject: [PATCH 1/2] fix(route): scmp (#14683) --- lib/routes/scmp/index.ts | 8 ++++---- lib/routes/scmp/utils.ts | 9 ++------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/lib/routes/scmp/index.ts b/lib/routes/scmp/index.ts index 4d029b257..cb50e24da 100644 --- a/lib/routes/scmp/index.ts +++ b/lib/routes/scmp/index.ts @@ -2,7 +2,7 @@ import cache from '@/utils/cache'; import { load } from 'cheerio'; import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; -const { parseItem } = require('./utils'); +import { parseItem } from './utils'; export default async (ctx) => { const categoryId = ctx.req.param('category_id'); @@ -14,8 +14,8 @@ export default async (ctx) => { const list = $('item') .toArray() - .map((item) => { - item = $(item); + .map((elem) => { + const item = $(elem); const enclosure = item.find('enclosure').first(); const mediaContent = item.find('media\\:content').toArray()[0]; const thumbnail = item.find('media\\:thumbnail').toArray()[0]; @@ -43,7 +43,7 @@ export default async (ctx) => { }; }); - const items = await Promise.all(list.map((item) => cache.tryGet(item.link, () => parseItem))); + const items = await Promise.all(list.map((item) => cache.tryGet(item.link, () => parseItem(item)))); ctx.set('json', { items, diff --git a/lib/routes/scmp/utils.ts b/lib/routes/scmp/utils.ts index 540bd0941..4012480bf 100644 --- a/lib/routes/scmp/utils.ts +++ b/lib/routes/scmp/utils.ts @@ -2,7 +2,7 @@ import { load } from 'cheerio'; import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; -const renderHTML = (node) => { +export const renderHTML = (node) => { if (!node) { return ''; } @@ -59,7 +59,7 @@ const renderHTML = (node) => { } }; -const parseItem = async (item) => { +export const parseItem = async (item) => { const { data: response, url } = await got(item.link); if (new URL(url).hostname !== 'www.scmp.com') { @@ -85,8 +85,3 @@ const parseItem = async (item) => { return item; }; - -module.exports = { - renderHTML, - parseItem, -}; From 0a82e22fb715cd6ac64310aef2ee9c77734756c6 Mon Sep 17 00:00:00 2001 From: Tony Date: Wed, 6 Mar 2024 22:28:13 +0800 Subject: [PATCH 2/2] fix(route): techflowpost (#14684) --- lib/routes/techflowpost/express.ts | 28 +++++++++++++--------------- lib/routes/techflowpost/index.ts | 26 +++++++++++++------------- lib/routes/techflowpost/radar.ts | 6 +++--- website/docs/routes/finance.mdx | 10 ++++++++++ website/docs/routes/new-media.mdx | 10 ---------- 5 files changed, 39 insertions(+), 41 deletions(-) diff --git a/lib/routes/techflowpost/express.ts b/lib/routes/techflowpost/express.ts index 76efb3715..cf2270a8e 100644 --- a/lib/routes/techflowpost/express.ts +++ b/lib/routes/techflowpost/express.ts @@ -1,28 +1,26 @@ import got from '@/utils/got'; import timezone from '@/utils/timezone'; import { parseDate } from '@/utils/parse-date'; -import { unescapeAll } from 'markdown-it/lib/common/utils.mjs'; +import dayjs from 'dayjs'; export default async (ctx) => { const rootUrl = 'https://www.techflowpost.com'; - const apiRootUrl = 'https://data.techflowpost.com'; - const currentUrl = `${rootUrl}/express`; - const apiUrl = `${apiRootUrl}/api/pc/express/all?pageIndex=0&pageSize=${ctx.req.query('limit') ?? 50}`; + const currentUrl = `${rootUrl}/newsletter/index.html`; - const response = await got({ - method: 'post', - url: apiUrl, - json: { - createTime: [], + const { data: response } = await got.post('https://www.techflowpost.com/ashx/newflash_index.ashx', { + form: { + pageindex: 1, + pagesize: ctx.req.query('limit') ?? 50, + time: dayjs().format('YYYY/M/D HH:mm:ss'), }, }); - const items = response.data.content.map((item) => ({ - title: item.title, - link: `${rootUrl}/express/${item.id}`, - category: item.tags?.split(',') ?? [], - pubDate: timezone(parseDate(item.createTime), +8), - description: unescapeAll(item.content), + const items = response.content.map((item) => ({ + title: item.stitle, + link: `${rootUrl}/newsletter/detail_${item.nnewflash_id}.html`, + pubDate: timezone(parseDate(item.dcreate_time), +8), + updated: timezone(parseDate(item.dmodi_time), +8), + description: item.scontent, })); ctx.set('data', { diff --git a/lib/routes/techflowpost/index.ts b/lib/routes/techflowpost/index.ts index b233173d9..3ee9370e8 100644 --- a/lib/routes/techflowpost/index.ts +++ b/lib/routes/techflowpost/index.ts @@ -1,25 +1,25 @@ import got from '@/utils/got'; import timezone from '@/utils/timezone'; import { parseDate } from '@/utils/parse-date'; -import { unescapeAll } from 'markdown-it/lib/common/utils.mjs'; export default async (ctx) => { const rootUrl = 'https://www.techflowpost.com'; - const apiRootUrl = 'https://data.techflowpost.com'; - const apiUrl = `${apiRootUrl}/api/pc/home/more?pageIndex=0&pageSize=${ctx.req.query('limit') ?? 50}`; - const response = await got({ - method: 'get', - url: apiUrl, + const { data: response } = await got.post('https://www.techflowpost.com/ashx/index.ashx', { + form: { + pageindex: 1, + pagesize: ctx.req.query('limit') ?? 50, + }, }); - const items = response.data.content.map((item) => ({ - title: item.title, - author: item.source, - link: `${rootUrl}/article/${item.id}`, - category: item.tagList.map((t) => t.name), - pubDate: timezone(parseDate(item.createTime), +8), - description: unescapeAll(item.content), + const items = response.content.map((item) => ({ + title: item.stitle, + author: item.sauthor_name, + link: `${rootUrl}/article/detail_${item.narticle_id}.html`, + category: [item.new_scata_name], + pubDate: timezone(parseDate(item.dcreate_time), +8), + updated: timezone(parseDate(item.dmodi_time), +8), + description: item.scontent, })); ctx.set('data', { diff --git a/lib/routes/techflowpost/radar.ts b/lib/routes/techflowpost/radar.ts index e0c1558e4..428158861 100644 --- a/lib/routes/techflowpost/radar.ts +++ b/lib/routes/techflowpost/radar.ts @@ -4,14 +4,14 @@ export default { '.': [ { title: '首页', - docs: 'https://docs.rsshub.app/routes/new-media#shen-chao-techflow-shou-ye', + docs: 'https://docs.rsshub.app/routes/finance#shen-chao-techflow-shou-ye', source: ['/'], target: '/techflowpost', }, { title: '快讯', - docs: 'https://docs.rsshub.app/routes/new-media#shen-chao-techflow-kuai-xun', - source: ['/express'], + docs: 'https://docs.rsshub.app/routes/finance#shen-chao-techflow-kuai-xun', + source: ['/newsletter/index.html'], target: '/techflowpost/express', }, ], diff --git a/website/docs/routes/finance.mdx b/website/docs/routes/finance.mdx index 49de89011..5554f7a04 100644 --- a/website/docs/routes/finance.mdx +++ b/website/docs/routes/finance.mdx @@ -617,6 +617,16 @@ TokenInsight also provides official RSS, you can take a look at [https://api.tok +## 深潮 TechFlow {#shen-chao-techflow} + +### 首页 {#shen-chao-techflow-shou-ye} + + + +### 快讯 {#shen-chao-techflow-kuai-xun} + + + ## 深圳证券交易所 {#shen-zhen-zheng-quan-jiao-yi-suo} ### 上市公告 - 可转换债券 {#shen-zhen-zheng-quan-jiao-yi-suo-shang-shi-gong-gao-ke-zhuan-huan-zhai-quan} diff --git a/website/docs/routes/new-media.mdx b/website/docs/routes/new-media.mdx index 2dc9f08ec..1f5b8970a 100644 --- a/website/docs/routes/new-media.mdx +++ b/website/docs/routes/new-media.mdx @@ -4240,16 +4240,6 @@ -## 深潮 TechFlow {#shen-chao-techflow} - -### 首页 {#shen-chao-techflow-shou-ye} - - - -### 快讯 {#shen-chao-techflow-kuai-xun} - - - ## 深圳新闻网 {#shen-zhen-xin-wen-wang} ### 深圳市政府新闻发布厅 {#shen-zhen-xin-wen-wang-shen-zhen-shi-zheng-fu-xin-wen-fa-bu-ting}