From 42014ee78e16aa04aad164c77a9b356ffb503f0f Mon Sep 17 00:00:00 2001 From: Zhenlong Huang Date: Fri, 5 Apr 2024 19:13:47 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20=E6=B7=BB=E5=8A=A0Binance?= =?UTF-8?q?=E6=95=B0=E5=AD=97=E8=B4=A7=E5=B8=81=E5=8F=8A=E4=BA=A4=E6=98=93?= =?UTF-8?q?=E5=AF=B9=E4=B8=8A=E6=96=B0=E5=85=AC=E5=91=8ARSS=20(#15103)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 添加Binance数字货币及交易对上新 * Update code per review comments --- lib/routes/binance/launchpool.ts | 46 ++++++++++++++++++++++++++++++++ lib/routes/binance/namespace.ts | 6 +++++ 2 files changed, 52 insertions(+) create mode 100644 lib/routes/binance/launchpool.ts create mode 100644 lib/routes/binance/namespace.ts diff --git a/lib/routes/binance/launchpool.ts b/lib/routes/binance/launchpool.ts new file mode 100644 index 000000000..5e8be2362 --- /dev/null +++ b/lib/routes/binance/launchpool.ts @@ -0,0 +1,46 @@ +import { Route } from '@/types'; +import got from '@/utils/got'; +import { load } from 'cheerio'; +import { parseDate } from '@/utils/parse-date'; + +export const route: Route = { + path: '/launchpool', + categories: ['finance'], + example: '/binance/launchpool', + radar: [ + { + source: ['binance.com/:lang/support/announcement'], + }, + ], + name: 'Binance数字货币及交易对上新', + maintainers: ['zhenlohuang'], + handler, +}; + +async function handler() { + const baseUrl = 'https://www.binance.com/zh-CN/support/announcement'; + const url = `${baseUrl}/数字货币及交易对上新?c=48&navId=48`; + + const response = await got({ + url, + headers: { + Referer: 'https://www.binance.com/', + }, + }); + + const $ = load(response.data); + const appData = JSON.parse($('#__APP_DATA').text()); + const articles = appData.appState.loader.dataByRouteId.d969.catalogs.find((catalog) => catalog.catalogId === 48).articles.filter((article) => article.title.includes('币安新币挖矿上线')); + + return { + title: 'Binance | 数字货币及交易对上新', + link: url, + description: '数字货币及交易对上新', + item: articles.map((item) => ({ + title: item.title, + link: `${baseUrl}/${item.code}`, + description: item.title, + pubDate: parseDate(item.releaseDate), + })), + }; +} diff --git a/lib/routes/binance/namespace.ts b/lib/routes/binance/namespace.ts new file mode 100644 index 000000000..1e5203898 --- /dev/null +++ b/lib/routes/binance/namespace.ts @@ -0,0 +1,6 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: 'Binance', + url: 'binance.com', +};