From ae57261fb9b3c4d9d16afc15a8adf5f20cf9b344 Mon Sep 17 00:00:00 2001 From: Ou Date: Thu, 24 Oct 2024 22:57:00 +0800 Subject: [PATCH] feat(source): add fastbull.cn --- public/icons/fastbull.png | Bin 0 -> 4286 bytes server/sources/fastbull.ts | 57 +++++++++++++++++++++++++++++++++ server/sources/index.ts | 2 ++ shared/metadata.ts | 12 ++++++- shared/sources.ts | 16 +++++++++ shared/types.ts | 1 + src/components/column/card.tsx | 2 +- 7 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 public/icons/fastbull.png create mode 100644 server/sources/fastbull.ts diff --git a/public/icons/fastbull.png b/public/icons/fastbull.png new file mode 100644 index 0000000000000000000000000000000000000000..382a4714bcc49316a8bb7e040df1da0964c8ed72 GIT binary patch literal 4286 zcmZQzU<5)11qKkwutI==L5zWcK?8_^LJST-3=#(epqvml1VaQE7}h^v{6C6E!(cQG z430FASk3$&8Lz#I-(3sOF`}qP)|*n#{J(q#)BoPBjQc;!v}_D|f& zh@u`@FEU$Fp7nov3-kYV_wk#DtOvxVmi;hu-J@9WmUl39Fq%~RdH7iWOUOd7hy-d_ z!ptn2&Vn_}c?p(Z(d|c8hm9SU#|+mCGXt5%rUzY&9Q&mdSpT=L#qDpH8_?}atYQA2+JK64 zyAkG);(r?-mjBDH(6;=s_hj)zlPuALLeEenk9Rd*e=fpfEu9KQ;1SSS~Y) zxzi5d4g*@)?-_$y{#4CD#2+l)VKln^J_*eK{Zlb<)oh3v=<%;_!}7m)G7}i*_c8qk z+0Dj=2!D|I{o9H6Ke~Hh{D3q_K0>!2CXb6Yuq7@2ahXGo{ptoR|3U2qSXg7DaoLA1 rPK^DaauZbcnK-iiFPg;kf6X2Ic4KqTsMu(jjiv$Gr2*JDz(COeh|-ll literal 0 HcmV?d00001 diff --git a/server/sources/fastbull.ts b/server/sources/fastbull.ts new file mode 100644 index 0000000..2558b58 --- /dev/null +++ b/server/sources/fastbull.ts @@ -0,0 +1,57 @@ +import * as cheerio from "cheerio" +import type { NewsItem } from "@shared/types" + +const express = defineSource(async () => { + const baseURL = "https://www.fastbull.cn" + const html: any = await $fetch(`${baseURL}/express-news`) + const $ = cheerio.load(html) + const $main = $(".news-list") + const news: NewsItem[] = [] + $main.each((_, el) => { + const a = $(el).find(".title_name") + const url = a.attr("href") + const titleText = a.text() + const title = titleText.match(/【(.+)】/)?.[1] ?? titleText + const date = $(el).attr("data-date") + if (url && title && date) { + news.push({ + url: baseURL + url, + title: title.length < 4 ? titleText : title, + id: url, + pubDate: Number(date), + }) + } + }) + return news +}) + +const news = defineSource(async () => { + const baseURL = "https://www.fastbull.cn" + const html: any = await $fetch(`${baseURL}/news`) + const $ = cheerio.load(html) + const $main = $(".trending_type") + const news: NewsItem[] = [] + $main.each((_, el) => { + const a = $(el) + const url = a.attr("href") + const title = a.find(".title").text() + const date = a.find("[data-date]").attr("data-date") + if (url && title && date) { + news.push({ + url: baseURL + url, + title, + id: url, + pubDate: Number(date), + }) + } + }) + return news +}) + +export default defineSource( + { + "fastbull": express, + "fastbull-express": express, + "fastbull-news": news, + }, +) diff --git a/server/sources/index.ts b/server/sources/index.ts index 26a525c..851fb85 100644 --- a/server/sources/index.ts +++ b/server/sources/index.ts @@ -16,6 +16,7 @@ import xueqiu from "./xueqiu" import gelonghui from "./gelonghui" import tieba from "./tieba" import thepaper from "./thepaper" +import fastbull from "./fastbull" import type { SourceGetter } from "#/types" export const sourcesGetters = { @@ -28,6 +29,7 @@ export const sourcesGetters = { cankaoxiaoxi, thepaper, sputniknewscn, + ...fastbull, ...wallstreetcn, ...xueqiu, gelonghui, diff --git a/shared/metadata.ts b/shared/metadata.ts index 2045783..593b4ec 100644 --- a/shared/metadata.ts +++ b/shared/metadata.ts @@ -19,7 +19,17 @@ const originMetadata: Metadata = { }, finance: { name: "财经", - sources: ["cls-telegraph", "cls-depth", "wallstreetcn", "wallstreetcn-hot", "wallstreetcn-news", "xueqiu-hotstock", "gelonghui"], + sources: [ + "cls-telegraph", + "cls-depth", + "wallstreetcn", + "wallstreetcn-hot", + "wallstreetcn-news", + "xueqiu-hotstock", + "gelonghui", + "fastbull-express", + "fastbull-news", + ], }, focus: { name: "关注", diff --git a/shared/sources.ts b/shared/sources.ts index a608623..51f9658 100644 --- a/shared/sources.ts +++ b/shared/sources.ts @@ -169,6 +169,22 @@ export const originSources = { interval: Time.Realtime, home: "https://www.gelonghui.com", }, + "fastbull": { + name: "法布财经", + color: "emerald", + home: "https://www.fastbull.cn", + sub: { + express: { + title: "快讯", + type: "realtime", + interval: Time.Realtime, + }, + news: { + title: "头条", + interval: Time.Common, + }, + }, + }, } as const satisfies Record export const sources = genSources() diff --git a/shared/types.ts b/shared/types.ts index 7fd27ce..ce86227 100644 --- a/shared/types.ts +++ b/shared/types.ts @@ -75,6 +75,7 @@ export interface NewsItem { title: string url: string mobileUrl?: string + pubDate?: number | string extra?: Record } diff --git a/src/components/column/card.tsx b/src/components/column/card.tsx index ca943bf..5542d57 100644 --- a/src/components/column/card.tsx +++ b/src/components/column/card.tsx @@ -216,7 +216,7 @@ function NewsListTimeLine({ query }: Query) { - - {item?.extra?.date && } + {(item.pubDate || item.extra?.date) && }