From 6b579b54250ec9195e570815237e9d375c1bb417 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 25 Apr 2024 19:19:29 +0800 Subject: [PATCH 01/11] chore(deps-dev): bump vitest and @vitest/coverage-v8 (#15370) * chore(deps-dev): bump vitest and @vitest/coverage-v8 Bumps [vitest](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest) and [@vitest/coverage-v8](https://github.com/vitest-dev/vitest/tree/HEAD/packages/coverage-v8). These dependencies needed to be updated together. Updates `vitest` from 1.5.0 to 1.5.2 - [Release notes](https://github.com/vitest-dev/vitest/releases) - [Commits](https://github.com/vitest-dev/vitest/commits/v1.5.2/packages/vitest) Updates `@vitest/coverage-v8` from 1.5.0 to 1.5.2 - [Release notes](https://github.com/vitest-dev/vitest/releases) - [Commits](https://github.com/vitest-dev/vitest/commits/v1.5.2/packages/coverage-v8) --- updated-dependencies: - dependency-name: vitest dependency-type: direct:development update-type: version-update:semver-patch - dependency-name: "@vitest/coverage-v8" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * chore: fix pnpm install --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 4 +-- pnpm-lock.yaml | 66 +++++++++++++++++++++++++------------------------- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/package.json b/package.json index c468c22339105e..ec46fe7f01186a 100644 --- a/package.json +++ b/package.json @@ -155,7 +155,7 @@ "@typescript-eslint/eslint-plugin": "7.7.1", "@typescript-eslint/parser": "7.7.1", "@vercel/nft": "0.26.4", - "@vitest/coverage-v8": "1.5.0", + "@vitest/coverage-v8": "1.5.2", "eslint": "8.57.0", "eslint-config-prettier": "9.1.0", "eslint-nibble": "8.1.0", @@ -177,7 +177,7 @@ "typescript": "5.4.5", "unified": "11.0.4", "vite-tsconfig-paths": "4.3.2", - "vitest": "1.5.0" + "vitest": "1.5.2" }, "engines": { "node": ">=20" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 05ad720f16e39d..8079c8b150be40 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -317,8 +317,8 @@ devDependencies: specifier: 0.26.4 version: 0.26.4 '@vitest/coverage-v8': - specifier: 1.5.0 - version: 1.5.0(vitest@1.5.0) + specifier: 1.5.2 + version: 1.5.2(vitest@1.5.2) eslint: specifier: 8.57.0 version: 8.57.0 @@ -383,8 +383,8 @@ devDependencies: specifier: 4.3.2 version: 4.3.2(typescript@5.4.5) vitest: - specifier: 1.5.0 - version: 1.5.0(@types/node@20.12.7)(jsdom@24.0.0) + specifier: 1.5.2 + version: 1.5.2(@types/node@20.12.7)(jsdom@24.0.0) packages: @@ -3275,10 +3275,10 @@ packages: - supports-color dev: true - /@vitest/coverage-v8@1.5.0(vitest@1.5.0): - resolution: {integrity: sha512-1igVwlcqw1QUMdfcMlzzY4coikSIBN944pkueGi0pawrX5I5Z+9hxdTR+w3Sg6Q3eZhvdMAs8ZaF9JuTG1uYOQ==} + /@vitest/coverage-v8@1.5.2(vitest@1.5.2): + resolution: {integrity: sha512-QJqxRnbCwNtbbegK9E93rBmhN3dbfG1bC/o52Bqr0zGCYhQzwgwvrJBG7Q8vw3zilX6Ryy6oa/mkZku2lLJx1Q==} peerDependencies: - vitest: 1.5.0 + vitest: 1.5.2 dependencies: '@ampproject/remapping': 2.3.0 '@bcoe/v8-coverage': 0.2.3 @@ -3293,43 +3293,43 @@ packages: std-env: 3.7.0 strip-literal: 2.0.0 test-exclude: 6.0.0 - vitest: 1.5.0(@types/node@20.12.7)(jsdom@24.0.0) + vitest: 1.5.2(@types/node@20.12.7)(jsdom@24.0.0) transitivePeerDependencies: - supports-color dev: true - /@vitest/expect@1.5.0: - resolution: {integrity: sha512-0pzuCI6KYi2SIC3LQezmxujU9RK/vwC1U9R0rLuGlNGcOuDWxqWKu6nUdFsX9tH1WU0SXtAxToOsEjeUn1s3hA==} + /@vitest/expect@1.5.2: + resolution: {integrity: sha512-rf7MTD1WCoDlN3FfYJ9Llfp0PbdtOMZ3FIF0AVkDnKbp3oiMW1c8AmvRZBcqbAhDUAvF52e9zx4WQM1r3oraVA==} dependencies: - '@vitest/spy': 1.5.0 - '@vitest/utils': 1.5.0 + '@vitest/spy': 1.5.2 + '@vitest/utils': 1.5.2 chai: 4.4.1 dev: true - /@vitest/runner@1.5.0: - resolution: {integrity: sha512-7HWwdxXP5yDoe7DTpbif9l6ZmDwCzcSIK38kTSIt6CFEpMjX4EpCgT6wUmS0xTXqMI6E/ONmfgRKmaujpabjZQ==} + /@vitest/runner@1.5.2: + resolution: {integrity: sha512-7IJ7sJhMZrqx7HIEpv3WrMYcq8ZNz9L6alo81Y6f8hV5mIE6yVZsFoivLZmr0D777klm1ReqonE9LyChdcmw6g==} dependencies: - '@vitest/utils': 1.5.0 + '@vitest/utils': 1.5.2 p-limit: 5.0.0 pathe: 1.1.2 dev: true - /@vitest/snapshot@1.5.0: - resolution: {integrity: sha512-qpv3fSEuNrhAO3FpH6YYRdaECnnRjg9VxbhdtPwPRnzSfHVXnNzzrpX4cJxqiwgRMo7uRMWDFBlsBq4Cr+rO3A==} + /@vitest/snapshot@1.5.2: + resolution: {integrity: sha512-CTEp/lTYos8fuCc9+Z55Ga5NVPKUgExritjF5VY7heRFUfheoAqBneUlvXSUJHUZPjnPmyZA96yLRJDP1QATFQ==} dependencies: magic-string: 0.30.8 pathe: 1.1.2 pretty-format: 29.7.0 dev: true - /@vitest/spy@1.5.0: - resolution: {integrity: sha512-vu6vi6ew5N5MMHJjD5PoakMRKYdmIrNJmyfkhRpQt5d9Ewhw9nZ5Aqynbi3N61bvk9UvZ5UysMT6ayIrZ8GA9w==} + /@vitest/spy@1.5.2: + resolution: {integrity: sha512-xCcPvI8JpCtgikT9nLpHPL1/81AYqZy1GCy4+MCHBE7xi8jgsYkULpW5hrx5PGLgOQjUpb6fd15lqcriJ40tfQ==} dependencies: tinyspy: 2.2.1 dev: true - /@vitest/utils@1.5.0: - resolution: {integrity: sha512-BDU0GNL8MWkRkSRdNFvCUCAVOeHaUlVJ9Tx0TYBZyXaaOTmGtUFObzchCivIBrIwKzvZA7A9sCejVhXM2aY98A==} + /@vitest/utils@1.5.2: + resolution: {integrity: sha512-sWOmyofuXLJ85VvXNsroZur7mOJGiQeM0JN3/0D1uU8U9bGFM69X1iqHaRXl6R8BwaLY6yPCogP257zxTzkUdA==} dependencies: diff-sequences: 29.6.3 estree-walker: 3.0.3 @@ -9533,8 +9533,8 @@ packages: vfile-message: 4.0.2 dev: true - /vite-node@1.5.0(@types/node@20.12.7): - resolution: {integrity: sha512-tV8h6gMj6vPzVCa7l+VGq9lwoJjW8Y79vst8QZZGiuRAfijU+EEWuc0kFpmndQrWhMMhet1jdSF+40KSZUqIIw==} + /vite-node@1.5.2(@types/node@20.12.7): + resolution: {integrity: sha512-Y8p91kz9zU+bWtF7HGt6DVw2JbhyuB2RlZix3FPYAYmUyZ3n7iTp8eSyLyY6sxtPegvxQtmlTMhfPhUfCUF93A==} engines: {node: ^18.0.0 || >=20.0.0} hasBin: true dependencies: @@ -9606,15 +9606,15 @@ packages: fsevents: 2.3.3 dev: true - /vitest@1.5.0(@types/node@20.12.7)(jsdom@24.0.0): - resolution: {integrity: sha512-d8UKgR0m2kjdxDWX6911uwxout6GHS0XaGH1cksSIVVG8kRlE7G7aBw7myKQCvDI5dT4j7ZMa+l706BIORMDLw==} + /vitest@1.5.2(@types/node@20.12.7)(jsdom@24.0.0): + resolution: {integrity: sha512-l9gwIkq16ug3xY7BxHwcBQovLZG75zZL0PlsiYQbf76Rz6QGs54416UWMtC0jXeihvHvcHrf2ROEjkQRVpoZYw==} engines: {node: ^18.0.0 || >=20.0.0} hasBin: true peerDependencies: '@edge-runtime/vm': '*' '@types/node': ^18.0.0 || >=20.0.0 - '@vitest/browser': 1.5.0 - '@vitest/ui': 1.5.0 + '@vitest/browser': 1.5.2 + '@vitest/ui': 1.5.2 happy-dom: '*' jsdom: '*' peerDependenciesMeta: @@ -9632,11 +9632,11 @@ packages: optional: true dependencies: '@types/node': 20.12.7 - '@vitest/expect': 1.5.0 - '@vitest/runner': 1.5.0 - '@vitest/snapshot': 1.5.0 - '@vitest/spy': 1.5.0 - '@vitest/utils': 1.5.0 + '@vitest/expect': 1.5.2 + '@vitest/runner': 1.5.2 + '@vitest/snapshot': 1.5.2 + '@vitest/spy': 1.5.2 + '@vitest/utils': 1.5.2 acorn-walk: 8.3.2 chai: 4.4.1 debug: 4.3.4 @@ -9651,7 +9651,7 @@ packages: tinybench: 2.6.0 tinypool: 0.8.3 vite: 5.2.9(@types/node@20.12.7) - vite-node: 1.5.0(@types/node@20.12.7) + vite-node: 1.5.2(@types/node@20.12.7) why-is-node-running: 2.2.2 transitivePeerDependencies: - less From f62f12da1cc58e636b801dc3d84979ec0a9da305 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=B5=A9=E5=AE=87?= <37102468+HaoyuLee@users.noreply.github.com> Date: Thu, 25 Apr 2024 20:18:02 +0800 Subject: [PATCH 02/11] feat: add route /gov/zj/search/:websiteid?/:word/:cateid? (#15359) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: 浙江省人民政府-统一搜索结果 * refactor: 浙江省人民政府-统一搜索结果-代码规范修正、description字段补充 * Update lib/routes/gov/zj/search.ts Co-authored-by: Tony * Update lib/routes/gov/zj/search.ts Co-authored-by: Tony * Update lib/routes/gov/zj/search.ts Co-authored-by: Tony --------- Co-authored-by: lihaoyu --- lib/routes/gov/zj/search.ts | 78 +++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 lib/routes/gov/zj/search.ts diff --git a/lib/routes/gov/zj/search.ts b/lib/routes/gov/zj/search.ts new file mode 100644 index 00000000000000..37dc20fc63fb18 --- /dev/null +++ b/lib/routes/gov/zj/search.ts @@ -0,0 +1,78 @@ +import { Route } from '@/types'; +import { parseDate } from '@/utils/parse-date'; +import got from '@/utils/got'; +import { load } from 'cheerio'; +import dayjs from 'dayjs'; + +export const route: Route = { + path: '/zj/search/:websiteid?/:word/:cateid?', + categories: ['government'], + example: '/gov/zj/search', + parameters: { + websiteid: '搜索范围-全省、各市各区、详细信息点击源网站https://www.zj.gov.cn/请求中寻找', + word: '搜索关键词-默认:人才', + cateid: '信息分类-默认:658(全部)', + sortType: '排序类型-默认:2(按时间)', + }, + radar: [{ + source: ['search.zj.gov.cn/jsearchfront/search.do'], + target: '/zj/search/:websiteid?/:word/:cateid?', + }], + name: '浙江省人民政府-全省政府网站统一搜索', + url: 'search.zj.gov.cn/jsearchfront/search.do', + maintainers: ['HaoyuLee'], + description: ` + | 行政区域 | websiteid | + | ------------ | -- | + | 宁波市本级 | 330201000000000 | + + | 搜索关键词 | word | + + | 信息分类 | cateid | + + | 排序类型 | sortType | + | ------------ | -- | + | 按相关度 | 1 | + | 按时间 | 2 | + `, + async handler(ctx) { + const { websiteid = '330201000000000', word = '人才', cateid = 658, sortType = 2 } = ctx.req.param(); + const { + data: { result: list }, + } = await got.post('https://search.zj.gov.cn/jsearchfront/interfaces/cateSearch.do', { + form: { + websiteid, + pg: '30', + p: '1', + cateid, + word, + checkError: 1, + isContains: 0, + q: word, + begin: dayjs().subtract(1, 'week').format('YYYYMMDD'), + end: dayjs().format('YYYYMMDD'), + timetype: 2, + pos: 'title,content,keyword', + sortType, + }, + }); + const items = + list?.map((item: string) => { + const $ = load(item); + const title = $('.titleWrapper>a'); + const footer = $('.sourceTime>span'); + return { + title: title.text().trim() || '', + link: title.attr('href') || '', + pubDate: parseDate(footer.eq(1).text().trim().replace('时间:', '')) || '', + author: footer.eq(0).text().trim().replace('来源:', '') || '', + description: $('.newsDescribe>a').text() || '', + }; + }) || []; + return { + title: '浙江省人民政府-全省政府网站统一搜索', + link: 'https://search.zj.gov.cn/jsearchfront/search.do', + item: items, + }; + }, +}; From c68e2b4af88cfb0c89cf6b818eb80c7a159733b6 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 25 Apr 2024 12:19:49 +0000 Subject: [PATCH 03/11] style: auto format --- lib/routes/gov/zj/search.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/routes/gov/zj/search.ts b/lib/routes/gov/zj/search.ts index 37dc20fc63fb18..e3f2942fababfb 100644 --- a/lib/routes/gov/zj/search.ts +++ b/lib/routes/gov/zj/search.ts @@ -14,10 +14,12 @@ export const route: Route = { cateid: '信息分类-默认:658(全部)', sortType: '排序类型-默认:2(按时间)', }, - radar: [{ - source: ['search.zj.gov.cn/jsearchfront/search.do'], - target: '/zj/search/:websiteid?/:word/:cateid?', - }], + radar: [ + { + source: ['search.zj.gov.cn/jsearchfront/search.do'], + target: '/zj/search/:websiteid?/:word/:cateid?', + }, + ], name: '浙江省人民政府-全省政府网站统一搜索', url: 'search.zj.gov.cn/jsearchfront/search.do', maintainers: ['HaoyuLee'], From 9f0c08e629db396dbd93c197e4f947d75b6844e5 Mon Sep 17 00:00:00 2001 From: wrvsrx <42770726+wrvsrx@users.noreply.github.com> Date: Thu, 25 Apr 2024 20:53:56 +0800 Subject: [PATCH 04/11] chore(deps): mark `tosource` as production dependency (#15356) Close #15093. Otherwise, `pnpm build` would fail after `pnpm install --production` --- lib/routes/mckinsey/cn/index.ts | 11 ++++------- package.json | 2 +- pnpm-lock.yaml | 22 ++++++++++++++-------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/lib/routes/mckinsey/cn/index.ts b/lib/routes/mckinsey/cn/index.ts index 95f4ae76408340..2ca56154073dc4 100644 --- a/lib/routes/mckinsey/cn/index.ts +++ b/lib/routes/mckinsey/cn/index.ts @@ -1,8 +1,5 @@ import { Route } from '@/types'; -// use stock `got` package as a workaround for -// https://github.com/DIYgod/RSSHub/issues/8239 -// https://github.com/DIYgod/RSSHub/pull/8288 -import got from 'got'; +import ofetch from '@/utils/ofetch'; import { parseDate } from '@/utils/parse-date'; import { categories } from './category-map'; @@ -53,12 +50,12 @@ async function handler(ctx) { categories.find((c) => c.slug === category); } - const posts = await got(`${endpoint}/wp/v2/posts`, { - searchParams: { + const posts = await ofetch(`${endpoint}/wp/v2/posts`, { + query: { per_page: ctx.req.query('limit') ? Number(ctx.req.query('limit')) : 50, categories: category, }, - }).json(); + }); const items = posts.map((item) => ({ title: item.title.rendered, diff --git a/package.json b/package.json index ec46fe7f01186a..44112cad17eb31 100644 --- a/package.json +++ b/package.json @@ -114,6 +114,7 @@ "tiny-async-pool": "2.1.0", "title": "3.5.3", "tldts": "6.1.18", + "tosource": "2.0.0-alpha.3", "tough-cookie": "4.1.3", "tsx": "4.7.2", "twitter-api-v2": "1.16.3", @@ -173,7 +174,6 @@ "prettier": "3.2.5", "remark-parse": "11.0.0", "supertest": "7.0.0", - "tosource": "2.0.0-alpha.3", "typescript": "5.4.5", "unified": "11.0.4", "vite-tsconfig-paths": "4.3.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8079c8b150be40..46b1fb97dec75d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -197,6 +197,9 @@ dependencies: tldts: specifier: 6.1.18 version: 6.1.18 + tosource: + specifier: 2.0.0-alpha.3 + version: 2.0.0-alpha.3 tough-cookie: specifier: 4.1.3 version: 4.1.3 @@ -370,9 +373,6 @@ devDependencies: supertest: specifier: 7.0.0 version: 7.0.0 - tosource: - specifier: 2.0.0-alpha.3 - version: 2.0.0-alpha.3 typescript: specifier: 5.4.5 version: 5.4.5 @@ -3005,8 +3005,8 @@ packages: resolution: {integrity: sha512-jmIUGWrAiwu3dZpxntxieC+1n/5c3mjrImkmOSQ2NC5uP6cYO4aAZDdSmRcI5C1oiTmqlZGHC+/NmJrKogbP5A==} dev: true - /@types/superagent@8.1.3: - resolution: {integrity: sha512-R/CfN6w2XsixLb1Ii8INfn+BT9sGPvw74OavfkW4SwY+jeUcAwLZv2+bXLJkndnimxjEBm0RPHgcjW9pLCa8cw==} + /@types/superagent@8.1.6: + resolution: {integrity: sha512-yzBOv+6meEHSzV2NThYYOA6RtqvPr3Hbob9ZLp3i07SH27CrYVfm8CrF7ydTmidtelsFiKx2I4gZAiAOamGgvQ==} dependencies: '@types/cookiejar': 2.1.5 '@types/methods': 1.1.4 @@ -3017,7 +3017,7 @@ packages: resolution: {integrity: sha512-137ypx2lk/wTQbW6An6safu9hXmajAifU/s7szAHLN/FeIm5w7yR0Wkl9fdJMRSHwOn4HLAI0DaB2TOORuhPDg==} dependencies: '@types/methods': 1.1.4 - '@types/superagent': 8.1.3 + '@types/superagent': 8.1.6 dev: true /@types/tiny-async-pool@2.0.3: @@ -7822,7 +7822,7 @@ packages: dependencies: nanoid: 3.3.7 picocolors: 1.0.0 - source-map-js: 1.2.0 + source-map-js: 1.0.2 dev: false /postcss@8.4.38: @@ -8679,9 +8679,15 @@ packages: atomic-sleep: 1.0.0 dev: false + /source-map-js@1.0.2: + resolution: {integrity: sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==} + engines: {node: '>=0.10.0'} + dev: false + /source-map-js@1.2.0: resolution: {integrity: sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==} engines: {node: '>=0.10.0'} + dev: true /source-map@0.5.7: resolution: {integrity: sha512-LbrmJOMUSdEVxIKvdcJzQC+nQhe8FUZQTXQy6+I75skNgn3OoQ0DZA8YnFa7gp8tqtL3KPf1kmo0R5DoApeSGQ==} @@ -9150,7 +9156,7 @@ packages: /tosource@2.0.0-alpha.3: resolution: {integrity: sha512-KAB2lrSS48y91MzFPFuDg4hLbvDiyTjOVgaK7Erw+5AmZXNq4sFRVn8r6yxSLuNs15PaokrDRpS61ERY9uZOug==} engines: {node: '>=10'} - dev: true + dev: false /tough-cookie@2.5.0: resolution: {integrity: sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==} From 218eb8a4fa721e8383f001423c449a6b88961e19 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 25 Apr 2024 22:02:24 +0000 Subject: [PATCH 05/11] chore(deps): bump lru-cache from 10.2.0 to 10.2.1 (#15375) * chore(deps): bump lru-cache from 10.2.0 to 10.2.1 Bumps [lru-cache](https://github.com/isaacs/node-lru-cache) from 10.2.0 to 10.2.1. - [Changelog](https://github.com/isaacs/node-lru-cache/blob/main/CHANGELOG.md) - [Commits](https://github.com/isaacs/node-lru-cache/compare/v10.2.0...v10.2.1) --- updated-dependencies: - dependency-name: lru-cache dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * chore: fix pnpm install --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- pnpm-lock.yaml | 24 +++++++++--------------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 44112cad17eb31..e07846d424548f 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "jsdom": "24.0.0", "json-bigint": "1.0.0", "jsrsasign": "10.9.0", - "lru-cache": "10.2.0", + "lru-cache": "10.2.1", "lz-string": "1.5.0", "mailparser": "3.7.0", "markdown-it": "14.1.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 46b1fb97dec75d..cda8e6df32e0b1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -114,8 +114,8 @@ dependencies: specifier: 10.9.0 version: 10.9.0 lru-cache: - specifier: 10.2.0 - version: 10.2.0 + specifier: 10.2.1 + version: 10.2.1 lz-string: specifier: 1.5.0 version: 1.5.0 @@ -3005,8 +3005,8 @@ packages: resolution: {integrity: sha512-jmIUGWrAiwu3dZpxntxieC+1n/5c3mjrImkmOSQ2NC5uP6cYO4aAZDdSmRcI5C1oiTmqlZGHC+/NmJrKogbP5A==} dev: true - /@types/superagent@8.1.6: - resolution: {integrity: sha512-yzBOv+6meEHSzV2NThYYOA6RtqvPr3Hbob9ZLp3i07SH27CrYVfm8CrF7ydTmidtelsFiKx2I4gZAiAOamGgvQ==} + /@types/superagent@8.1.3: + resolution: {integrity: sha512-R/CfN6w2XsixLb1Ii8INfn+BT9sGPvw74OavfkW4SwY+jeUcAwLZv2+bXLJkndnimxjEBm0RPHgcjW9pLCa8cw==} dependencies: '@types/cookiejar': 2.1.5 '@types/methods': 1.1.4 @@ -3017,7 +3017,7 @@ packages: resolution: {integrity: sha512-137ypx2lk/wTQbW6An6safu9hXmajAifU/s7szAHLN/FeIm5w7yR0Wkl9fdJMRSHwOn4HLAI0DaB2TOORuhPDg==} dependencies: '@types/methods': 1.1.4 - '@types/superagent': 8.1.6 + '@types/superagent': 8.1.3 dev: true /@types/tiny-async-pool@2.0.3: @@ -6761,8 +6761,8 @@ packages: resolution: {integrity: sha512-ozCC6gdQ+glXOQsveKD0YsDy8DSQFjDTz4zyzEHNV5+JP5D62LmfDZ6o1cycFx9ouG940M5dE8C8CTewdj2YWQ==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - /lru-cache@10.2.0: - resolution: {integrity: sha512-2bIM8x+VAf6JT4bKAljS1qUWgMsqZRPGJS6FSahIMPVvctcNhyVp7AJu7quxOW9jwkryBReKZY5tY5JYv2n/7Q==} + /lru-cache@10.2.1: + resolution: {integrity: sha512-tS24spDe/zXhWbNPErCHs/AGOzbKGHT+ybSBqmdLm8WZ1xXLWvH8Qn71QPAlqVhd0qUTWjy+Kl9JmISgDdEjsA==} engines: {node: 14 || >=16.14} /lru-cache@4.1.5: @@ -7723,7 +7723,7 @@ packages: resolution: {integrity: sha512-MkhCqzzBEpPvxxQ71Md0b1Kk51W01lrYvlMzSUaIzNsODdd7mqhiimSZlr+VegAz5Z6Vzt9Xg2ttE//XBhH3EQ==} engines: {node: '>=16 || 14 >=14.17'} dependencies: - lru-cache: 10.2.0 + lru-cache: 10.2.1 minipass: 5.0.0 dev: true @@ -7822,7 +7822,7 @@ packages: dependencies: nanoid: 3.3.7 picocolors: 1.0.0 - source-map-js: 1.0.2 + source-map-js: 1.2.0 dev: false /postcss@8.4.38: @@ -8679,15 +8679,9 @@ packages: atomic-sleep: 1.0.0 dev: false - /source-map-js@1.0.2: - resolution: {integrity: sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==} - engines: {node: '>=0.10.0'} - dev: false - /source-map-js@1.2.0: resolution: {integrity: sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==} engines: {node: '>=0.10.0'} - dev: true /source-map@0.5.7: resolution: {integrity: sha512-LbrmJOMUSdEVxIKvdcJzQC+nQhe8FUZQTXQy6+I75skNgn3OoQ0DZA8YnFa7gp8tqtL3KPf1kmo0R5DoApeSGQ==} From e13af5972b714dfa54ebf511fa4196fb8285b3b3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 25 Apr 2024 22:05:13 +0000 Subject: [PATCH 06/11] chore(deps): bump googleapis from 134.0.0 to 135.0.0 (#15378) * chore(deps): bump googleapis from 134.0.0 to 135.0.0 Bumps [googleapis](https://github.com/googleapis/google-api-nodejs-client) from 134.0.0 to 135.0.0. - [Release notes](https://github.com/googleapis/google-api-nodejs-client/releases) - [Changelog](https://github.com/googleapis/google-api-nodejs-client/blob/main/release-please-config.json) - [Commits](https://github.com/googleapis/google-api-nodejs-client/compare/googleapis-v134.0.0...googleapis-v135.0.0) --- updated-dependencies: - dependency-name: googleapis dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] * chore: fix pnpm install --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- pnpm-lock.yaml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index e07846d424548f..2b3348d08ac1c5 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,7 @@ "etag": "1.8.1", "fanfou-sdk": "5.0.0", "form-data": "4.0.0", - "googleapis": "134.0.0", + "googleapis": "135.0.0", "hono": "4.2.7", "html-to-text": "9.0.5", "https-proxy-agent": "7.0.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cda8e6df32e0b1..c52de0407f7d6f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -78,8 +78,8 @@ dependencies: specifier: 4.0.0 version: 4.0.0 googleapis: - specifier: 134.0.0 - version: 134.0.0 + specifier: 135.0.0 + version: 135.0.0 hono: specifier: 4.2.7 version: 4.2.7 @@ -5659,8 +5659,8 @@ packages: - supports-color dev: false - /googleapis@134.0.0: - resolution: {integrity: sha512-o8LhD1754W6MHWtpwAPeP1WUHgNxuMxCnLMDFlMKAA5kCMTNqX9/eaTXnkkAIv6YRfoKMQ6D1vyR6/biXuhE9g==} + /googleapis@135.0.0: + resolution: {integrity: sha512-gIbhO1ptjgg74DEO5WIiyO1l4zLL7Lssab0XoIdZ+TYArib4SwQbKObpidRBdYAixf/fmQd00JIYYx6JtpZzew==} engines: {node: '>=14.0.0'} dependencies: google-auth-library: 9.6.3 From 867c737f249e9c5b3c6daf6175bc428e09d387c4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 25 Apr 2024 22:05:50 +0000 Subject: [PATCH 07/11] chore(deps): bump tsx from 4.7.2 to 4.7.3 (#15376) * chore(deps): bump tsx from 4.7.2 to 4.7.3 Bumps [tsx](https://github.com/privatenumber/tsx) from 4.7.2 to 4.7.3. - [Release notes](https://github.com/privatenumber/tsx/releases) - [Changelog](https://github.com/privatenumber/tsx/blob/master/release.config.cjs) - [Commits](https://github.com/privatenumber/tsx/compare/v4.7.2...v4.7.3) --- updated-dependencies: - dependency-name: tsx dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * chore: fix pnpm install --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- pnpm-lock.yaml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 2b3348d08ac1c5..8bc268bdd0a607 100644 --- a/package.json +++ b/package.json @@ -116,7 +116,7 @@ "tldts": "6.1.18", "tosource": "2.0.0-alpha.3", "tough-cookie": "4.1.3", - "tsx": "4.7.2", + "tsx": "4.7.3", "twitter-api-v2": "1.16.3", "undici": "6.14.1", "uuid": "9.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c52de0407f7d6f..7872c2e84bc41a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -204,8 +204,8 @@ dependencies: specifier: 4.1.3 version: 4.1.3 tsx: - specifier: 4.7.2 - version: 4.7.2 + specifier: 4.7.3 + version: 4.7.3 twitter-api-v2: specifier: 1.16.3 version: 1.16.3 @@ -9231,8 +9231,8 @@ packages: /tslib@2.6.2: resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==} - /tsx@4.7.2: - resolution: {integrity: sha512-BCNd4kz6fz12fyrgCTEdZHGJ9fWTGeUzXmQysh0RVocDY3h4frk05ZNCXSy4kIenF7y/QnrdiVpTsyNRn6vlAw==} + /tsx@4.7.3: + resolution: {integrity: sha512-+fQnMqIp/jxZEXLcj6WzYy9FhcS5/Dfk8y4AtzJ6ejKcKqmfTF8Gso/jtrzDggCF2zTU20gJa6n8XqPYwDAUYQ==} engines: {node: '>=18.0.0'} hasBin: true dependencies: From 9b21ab112cdcbdff2cbd500b23b251656622900e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 25 Apr 2024 22:21:01 +0000 Subject: [PATCH 08/11] chore(deps): bump mailparser from 3.7.0 to 3.7.1 (#15379) * chore(deps): bump mailparser from 3.7.0 to 3.7.1 Bumps [mailparser](https://github.com/nodemailer/mailparser) from 3.7.0 to 3.7.1. - [Release notes](https://github.com/nodemailer/mailparser/releases) - [Changelog](https://github.com/nodemailer/mailparser/blob/master/CHANGELOG.md) - [Commits](https://github.com/nodemailer/mailparser/compare/v3.7.0...v3.7.1) --- updated-dependencies: - dependency-name: mailparser dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * chore: fix pnpm install --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- pnpm-lock.yaml | 37 ++++++++++++++----------------------- 2 files changed, 15 insertions(+), 24 deletions(-) diff --git a/package.json b/package.json index 8bc268bdd0a607..49347779594825 100644 --- a/package.json +++ b/package.json @@ -88,7 +88,7 @@ "jsrsasign": "10.9.0", "lru-cache": "10.2.1", "lz-string": "1.5.0", - "mailparser": "3.7.0", + "mailparser": "3.7.1", "markdown-it": "14.1.0", "module-alias": "2.2.3", "notion-to-md": "3.1.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7872c2e84bc41a..e687ceee2a9aaa 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -120,8 +120,8 @@ dependencies: specifier: 1.5.0 version: 1.5.0 mailparser: - specifier: 3.7.0 - version: 3.7.0 + specifier: 3.7.1 + version: 3.7.1 markdown-it: specifier: 14.1.0 version: 14.1.0 @@ -6553,15 +6553,6 @@ packages: libqp: 2.0.1 dev: false - /libmime@5.3.4: - resolution: {integrity: sha512-TsqPdercr6DHrnoQx1F0nS2Y4yPT+fWuOjEP2rqzvV77hMYWomTe/rpm0u9JORQ/FavEXybAGcBJsQbLr9+hjA==} - dependencies: - encoding-japanese: 2.0.0 - iconv-lite: 0.6.3 - libbase64: 1.3.0 - libqp: 2.1.0 - dev: false - /libmime@5.3.5: resolution: {integrity: sha512-nSlR1yRZ43L3cZCiWEw7ali3jY29Hz9CQQ96Oy+sSspYnIP5N54ucOPHqooBsXzwrX1pwn13VUE05q4WmzfaLg==} dependencies: @@ -6813,19 +6804,19 @@ packages: source-map-js: 1.2.0 dev: true - /mailparser@3.7.0: - resolution: {integrity: sha512-yFo1+4r3gHhTcazVGCv3D/uX5VJyyrx4iWkzKtJh8mujYIUm92kpG5BjKpZIJgEoKcKxbJVd4CPs+IImE1sKlQ==} + /mailparser@3.7.1: + resolution: {integrity: sha512-RCnBhy5q8XtB3mXzxcAfT1huNqN93HTYYyL6XawlIKycfxM/rXPg9tXoZ7D46+SgCS1zxKzw+BayDQSvncSTTw==} dependencies: - encoding-japanese: 2.0.0 + encoding-japanese: 2.1.0 he: 1.2.0 html-to-text: 9.0.5 iconv-lite: 0.6.3 - libmime: 5.3.4 + libmime: 5.3.5 linkify-it: 5.0.0 mailsplit: 5.4.0 - nodemailer: 6.9.11 - punycode: 2.3.1 - tlds: 1.250.0 + nodemailer: 6.9.13 + punycode.js: 2.3.1 + tlds: 1.252.0 dev: false /mailsplit@5.4.0: @@ -7358,11 +7349,6 @@ packages: resolution: {integrity: sha512-y10wOWt8yZpqXmOgRo77WaHEmhYQYGNA6y421PKsKYWEK8aW+cqAphborZDhqfyKrbZEN92CN1X2KbafY2s7Yw==} dev: true - /nodemailer@6.9.11: - resolution: {integrity: sha512-UiAkgiERuG94kl/3bKfE8o10epvDnl0vokNEtZDPTq9BWzIl6EFT9336SbIT4oaTBD8NmmUTLsQyXHV82eXSWg==} - engines: {node: '>=6.0.0'} - dev: false - /nodemailer@6.9.13: resolution: {integrity: sha512-7o38Yogx6krdoBf3jCAqnIN4oSQFx+fMa0I7dK1D+me9kBxx12D+/33wSb+fhOCtIxvYJ+4x4IMEhmhCKfAiOA==} engines: {node: '>=6.0.0'} @@ -9101,6 +9087,11 @@ packages: hasBin: true dev: false + /tlds@1.252.0: + resolution: {integrity: sha512-GA16+8HXvqtfEnw/DTcwB0UU354QE1n3+wh08oFjr6Znl7ZLAeUgYzCcK+/CCrOyE0vnHR8/pu3XXG3vDijXpQ==} + hasBin: true + dev: false + /tldts-core@6.1.18: resolution: {integrity: sha512-e4wx32F/7dMBSZyKAx825Yte3U0PQtZZ0bkWxYQiwLteRVnQ5zM40fEbi0IyNtwQssgJAk3GCr7Q+w39hX0VKA==} dev: false From e50b2c651591c59474bcc64ed1d87f1cecba9b79 Mon Sep 17 00:00:00 2001 From: Tony Date: Fri, 26 Apr 2024 07:10:46 +0800 Subject: [PATCH 09/11] feat(route): add back kpmg (#15373) --- lib/routes-deprecated/kpmg/insights.js | 79 ------------ lib/routes/kpmg/insights.ts | 143 ++++++++++++++++++++++ lib/routes/kpmg/namespace.ts | 10 ++ lib/routes/kpmg/templates/description.art | 11 ++ 4 files changed, 164 insertions(+), 79 deletions(-) delete mode 100644 lib/routes-deprecated/kpmg/insights.js create mode 100644 lib/routes/kpmg/insights.ts create mode 100644 lib/routes/kpmg/namespace.ts create mode 100644 lib/routes/kpmg/templates/description.art diff --git a/lib/routes-deprecated/kpmg/insights.js b/lib/routes-deprecated/kpmg/insights.js deleted file mode 100644 index ed9fb666a94740..00000000000000 --- a/lib/routes-deprecated/kpmg/insights.js +++ /dev/null @@ -1,79 +0,0 @@ -const got = require('@/utils/got'); -const cheerio = require('cheerio'); - -module.exports = async (ctx) => { - const link = 'https://home.kpmg/cn/zh/home/insights.html'; - - const response = await got({ - method: 'post', - url: `https://home.kpmg/esearch/cn-zh`, - headers: { - Referer: link, - }, - json: { - query: '', - filters: { - all: [ - { - kpmg_tab_type: ['Insights'], - }, - ], - }, - result_fields: { - kpmg_title: { - raw: {}, - }, - kpmg_article_date_time: { - raw: {}, - }, - kpmg_url: { - raw: {}, - }, - }, - page: { - size: 20, - current: 1, - }, - sort: { - kpmg_filter_date: 'desc', - }, - }, - }); - - const list = response.data.results.map((item) => ({ - title: item.kpmg_title.raw, - link: item.kpmg_url.raw, - pubDate: item.kpmg_article_date_time.raw, - })); - - const item = await Promise.all( - list.map((item) => - ctx.cache.tryGet(item.link, async () => { - const response = await got.get(item.link); - const $ = cheerio.load(response.data); - - if ($('a.component-link')) { - const link = $('a.component-link').attr('href'); - const size = $('a.component-link .downloadSize').text(); - $('a.component-link').replaceWith( - `

- - 点击下载 PDF ${size} -

` - ); - } - - item.description = $('.module-touch-columncontrol').html() || $('.display-full-width').html(); - - return item; - }) - ) - ); - - ctx.state.data = { - title: '毕马威洞察', - link, - description: '欢迎浏览毕马威中国网站的知识库。在这里,你可以找到毕马威中国各类定期出版的通讯及各通讯过往的期号。', - item, - }; -}; diff --git a/lib/routes/kpmg/insights.ts b/lib/routes/kpmg/insights.ts new file mode 100644 index 00000000000000..f5a87c46f10f89 --- /dev/null +++ b/lib/routes/kpmg/insights.ts @@ -0,0 +1,143 @@ +import InvalidParameterError from '@/errors/types/invalid-parameter'; +import { Route } from '@/types'; +import cache from '@/utils/cache'; +import ofetch from '@/utils/ofetch'; +import * as cheerio from 'cheerio'; +import { Context } from 'hono'; +import { parseDate } from '@/utils/parse-date'; +import { art } from '@/utils/render'; +import path from 'node:path'; +import { getCurrentPath } from '@/utils/helpers'; +const __dirname = getCurrentPath(import.meta.url); + +const baseUrl = 'https://kpmg.com'; +const payload = { + query: '', + filters: { + all: [{ kpmg_tab_type: ['Insights'] }, { kpmg_article_type: ['Article-General'] }, { kpmg_template_type: ['article-details-template', 'insights-flexible-template', 'editable-flex-template', 'editable-campaign-template'] }], + }, + result_fields: { + kpmg_description: { raw: {} }, + kpmg_banner_flag: { raw: {} }, + kpmg_primary_tag: { raw: {} }, + kpmg_article_date: { raw: {} }, + kpmg_contact_job_ttl: { raw: {} }, + kpmg_title: { raw: {} }, + kpmg_contact_city: { raw: {} }, + kpmg_event_start_time: { raw: {} }, + kpmg_article_date_time: { raw: {} }, + kpmg_tab_type: { raw: {} }, + kpmg_short_desc: { raw: {} }, + kpmg_image_alt: { raw: {} }, + kpmg_url: { raw: {} }, + kpmg_template_type: { raw: {} }, + kpmg_image: { raw: {} }, + kpmg_non_decorative_alt_text: { raw: {} }, + kpmg_article_readtime: { raw: {} }, + kpmg_contact_fn: { raw: {} }, + kpmg_contact_ln: { raw: {} }, + kpmg_event_type: { raw: {} }, + kpmg_contact_country: { raw: {} }, + kpmg_is_rendition_optimized: { raw: {} }, + kpmg_article_primary_format: { raw: {} }, + kpmg_article_type: { raw: {} }, + kpmg_event_startdate: { raw: {} }, + }, + page: { size: 20, current: 1 }, + sort: { kpmg_filter_date: 'desc' }, +}; +const endpoints = { + en: { + title: 'Insights - KPMG ', + link: `${baseUrl}/xx/en/home/insights.html`, + api: `${baseUrl}/esearch/xx-en`, + }, + zh: { + title: '洞察 - 毕马威', + link: `${baseUrl}/cn/zh/home/insights.html`, + api: `${baseUrl}/esearch/cn-zh`, + }, +}; +const render = (data) => art(path.join(__dirname, 'templates/description.art'), data); + +const handler = async (ctx: Context) => { + const { lang = 'en' } = ctx.req.param(); + const endpoint = endpoints[lang]; + if (!endpoint) { + throw new InvalidParameterError('Invalid language'); + } + const link = endpoint.link; + + const response = await ofetch(endpoint.api, { + method: 'POST', + body: payload, + }); + + const list = response.results.map((item) => ({ + title: item.kpmg_title.raw, + description: item.kpmg_description.raw, + link: item.kpmg_url.raw, + pubDate: parseDate(item.kpmg_article_date_time.raw), + image: item.kpmg_image.raw, + imageAlt: item.kpmg_image_alt?.raw, + })); + + const item = await Promise.all( + list.map((item) => + cache.tryGet(item.link, async () => { + const response = await ofetch(item.link); + const $ = cheerio.load(response); + + const content = $('.bodytext-data') + .toArray() + .map((item) => { + const element = $(item); + element.find('.hidden-xs, .sr-only').remove(); + return element.parent().html(); + }) + .join(''); + + const pdfDetails = $('.pdfdetails').parent().parent().parent(); + pdfDetails.find('.hidden-xs, .sr-only').remove(); + + item.description = render({ + image: item.image, + alt: item.imageAlt, + content, + pdf: pdfDetails.prop('outerHTML'), + }); + + return item; + }) + ) + ); + + return { + title: 'KPMG Insights', + link, + item, + }; +}; + +export const route: Route = { + path: '/insights/:lang?', + example: '/kpmg/insights', + parameters: { lang: 'Language, either `en` or `zh`' }, + radar: [ + { + source: ['kpmg.com/xx/en/home/insights.html'], + target: '/insights/en', + }, + { + source: ['kpmg.com/cn/zh/home/insights.html'], + target: '/insights/zh', + }, + ], + name: 'Insights', + maintainers: ['LogicJake'], + handler, + url: 'kpmg.com/xx/en/home/insights.html', + zh: { + name: '洞察', + }, +}; diff --git a/lib/routes/kpmg/namespace.ts b/lib/routes/kpmg/namespace.ts new file mode 100644 index 00000000000000..04ff3866e0a9d3 --- /dev/null +++ b/lib/routes/kpmg/namespace.ts @@ -0,0 +1,10 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: 'KPMG', + url: 'kpmg.com', + categories: ['other'], + zh: { + name: '毕马威', + }, +}; diff --git a/lib/routes/kpmg/templates/description.art b/lib/routes/kpmg/templates/description.art new file mode 100644 index 00000000000000..78ed654a1a406b --- /dev/null +++ b/lib/routes/kpmg/templates/description.art @@ -0,0 +1,11 @@ +{{ if image }} + +{{ /if }} + +{{ if content }} +
{{@ content }} +{{ /if }} + +{{ if pdf }} +
{{@ pdf }} +{{ /if }} From 97339cf78fdbb8ae567b63364670a1859331926a Mon Sep 17 00:00:00 2001 From: Ethan Shen <42264778+nczitzk@users.noreply.github.com> Date: Fri, 26 Apr 2024 07:32:09 +0800 Subject: [PATCH 10/11] =?UTF-8?q?feat(route):=20add=20=E7=BD=91=E7=8C=B4?= =?UTF-8?q?=E7=BA=BF=E6=8A=A5=20(#15372)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/routes/iehou/index.ts | 125 ++++++++++++++++++++++++++++++++++ lib/routes/iehou/namespace.ts | 8 +++ 2 files changed, 133 insertions(+) create mode 100644 lib/routes/iehou/index.ts create mode 100644 lib/routes/iehou/namespace.ts diff --git a/lib/routes/iehou/index.ts b/lib/routes/iehou/index.ts new file mode 100644 index 00000000000000..cee71b4b71c60e --- /dev/null +++ b/lib/routes/iehou/index.ts @@ -0,0 +1,125 @@ +import { Route } from '@/types'; + +import cache from '@/utils/cache'; +import got from '@/utils/got'; +import { load } from 'cheerio'; +import timezone from '@/utils/timezone'; +import { parseDate } from '@/utils/parse-date'; + +export const handler = async (ctx) => { + const { category = '' } = ctx.req.param(); + const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 100; + + const rootUrl = 'https://iehou.com'; + const currentUrl = new URL(category ? `page-${category}.htm` : '', rootUrl).href; + + const { data: response } = await got(currentUrl); + + const $ = load(response); + + const language = $('html').prop('lang'); + + let items = $('li.list-group-item div.subject h2') + .slice(0, limit) + .toArray() + .map((item) => { + item = $(item); + + const title = item.text(); + + return { + title, + pubDate: timezone(parseDate(item.parent().find('span').text(), 'MM-DD HH:mm', 'YYYY-MM-DD HH:mm'), +8), + link: item.find('a').prop('href'), + category: item + .nextAll('a') + .toArray() + .map((c) => $(c).text()), + language, + }; + }); + + items = await Promise.all( + items.map((item) => + cache.tryGet(item.link, async () => { + const { data: detailResponse } = await got(item.link); + + const $$ = load(detailResponse); + + const title = $$('h1.title').text(); + const description = $$('div.thread-content').html(); + const image = $$('div.thread-content img').first().prop('src'); + + item.title = title; + item.description = description; + item.pubDate = timezone(parseDate($$('i.icon-clock-o').parent().contents().last().text().trim(), 'MM-DD HH:mm', 'YYYY-MM-DD HH:mm'), +8); + item.author = $$('img.avatar-1').parent().contents().last().text().trim(); + item.content = { + html: description, + text: $$('div.thread-content').text(), + }; + item.image = image; + item.banner = image; + item.language = language; + + return item; + }) + ) + ); + + return { + title: $('title').text(), + description: $('meta[name="description"]').prop('content'), + link: currentUrl, + item: items, + allowEmpty: true, + author: $('h1').text(), + language, + }; +}; + +export const route: Route = { + path: '/:category?', + name: '线报', + url: 'iehou.com', + maintainers: ['nczitzk'], + handler, + example: '/iehou', + parameters: { category: '分类,默认为空,即最新线报,可在对应分类页 URL 中找到' }, + description: `:::tip + 若订阅 [24小时热门线报](https://iehou.com/page-dayhot.htm),网址为 \`https://iehou.com/page-dayhot.htm\`。截取 \`https://iehou.com/page-\` 到末尾 \`.htm\` 的部分 \`dayhot\` 作为参数填入,此时路由为 [\`/iehou/dayhot\`](https://rsshub.app/iehou/dayhot)。 + ::: + + | [最新线报](https://iehou.com/) | [24 小时热门](https://iehou.com/page-dayhot.htm) | [一周热门](https://iehou.com/page-weekhot.htm) | + | ------------------------------ | ------------------------------------------------ | ---------------------------------------------- | + | [](https://rsshub.app/iehou) | [dayhot](https://rsshub.app/iehou/dayhot) | [weekhot](https://rsshub.app/iehou/weekhot) | + `, + categories: ['new-media'], + + features: { + requireConfig: false, + requirePuppeteer: false, + antiCrawler: false, + supportRadar: true, + supportBT: false, + supportPodcast: false, + supportScihub: false, + }, + radar: [ + { + title: '最新线报', + source: ['iehou.com'], + target: '/', + }, + { + title: '24小时热门', + source: ['iehou.com/page-dayhot.htm'], + target: '/dayhot', + }, + { + title: '一周热门', + source: ['iehou.com/page-weekhot.htm'], + target: '/weekhot', + }, + ], +}; diff --git a/lib/routes/iehou/namespace.ts b/lib/routes/iehou/namespace.ts new file mode 100644 index 00000000000000..75cb601d83e56b --- /dev/null +++ b/lib/routes/iehou/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '网猴线报', + url: 'iehou.com', + categories: ['new-media'], + description: '', +}; From 7e87a4823eac6025043c0a250939ad329197ad89 Mon Sep 17 00:00:00 2001 From: DIYgod Date: Fri, 26 Apr 2024 08:59:44 +0800 Subject: [PATCH 11/11] feat: add layout and use sn pro font --- lib/views/error.tsx | 24 +-------------------- lib/views/index.tsx | 30 ++++---------------------- lib/views/layout.tsx | 50 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 49 deletions(-) create mode 100644 lib/views/layout.tsx diff --git a/lib/views/error.tsx b/lib/views/error.tsx index cc63e064da545e..50e724b8f50e43 100644 --- a/lib/views/error.tsx +++ b/lib/views/error.tsx @@ -1,30 +1,8 @@ import type { FC } from 'hono/jsx'; +import { Layout } from '@/views/layout'; import { gitHash, gitDate } from '@/utils/git-hash'; -const Layout: FC = (props) => ( - - - Welcome to RSSHub! - - - - {props.children} - -); - const Index: FC<{ requestPath: string; message: string; diff --git a/lib/views/index.tsx b/lib/views/index.tsx index 03850b6a8c9c73..cc5394000c06e9 100644 --- a/lib/views/index.tsx +++ b/lib/views/index.tsx @@ -1,34 +1,12 @@ import type { FC } from 'hono/jsx'; +import { Layout } from '@/views/layout'; import { config } from '@/config'; import { gitHash, gitDate } from '@/utils/git-hash'; import { getDebugInfo } from '@/utils/debug-info'; const startTime = Date.now(); -const Layout: FC = (props) => ( - - - Welcome to RSSHub! - - - - {props.children} - -); - const Index: FC<{ debugQuery: string | undefined }> = ({ debugQuery }) => { const debug = getDebugInfo(); @@ -166,13 +144,13 @@ const Index: FC<{ debugQuery: string | undefined }> = ({ debugQuery }) => {

Everything is RSSible

{info.showDebug ? ( diff --git a/lib/views/layout.tsx b/lib/views/layout.tsx new file mode 100644 index 00000000000000..f988bda2d40b10 --- /dev/null +++ b/lib/views/layout.tsx @@ -0,0 +1,50 @@ +import type { FC } from 'hono/jsx'; + +export const Layout: FC = (props) => ( + + + Welcome to RSSHub! + + + + {props.children} + +);