diff --git a/server/sources/gelonghui.ts b/server/sources/gelonghui.ts new file mode 100644 index 0000000..92f5aa4 --- /dev/null +++ b/server/sources/gelonghui.ts @@ -0,0 +1,31 @@ +import * as cheerio from "cheerio" +import type { NewsItem } from "@shared/types" + +export default defineSource(async () => { + const baseURL = "https://www.gelonghui.com" + const html: any = await $fetch("https://www.gelonghui.com/news") + const $ = cheerio.load(html) + const $main = $(".article-content") + const news: NewsItem[] = [] + $main.each((_, el) => { + const a = $(el).find(".detail-right>a") + // https://www.kzaobao.com/shiju/20241002/170659.html + const url = a.attr("href") + const title = a.find("h2").text() + const info = $(el).find(".about-stocks").text() + // 第三个 p + const relatieveTime = $(el).find(".time > span:nth-child(3)").text() + if (url && title && relatieveTime) { + news.push({ + url: baseURL + url, + title, + id: url, + extra: { + date: parseRelativeDate(relatieveTime).toDateString(), + info, + }, + }) + } + }) + return news.sort((m, n) => n.extra!.date > m.extra!.date ? 1 : -1) +}) diff --git a/server/sources/index.ts b/server/sources/index.ts index 35edad0..75bcce2 100644 --- a/server/sources/index.ts +++ b/server/sources/index.ts @@ -13,6 +13,7 @@ import toutiao from "./toutiao" import cls from "./cls" import sputniknewscn from "./sputniknewscn" import xueqiu from "./xueqiu" +import gelonghui from "./gelonghui" import type { SourceGetter } from "#/types" export const sourcesGetters = { @@ -26,6 +27,7 @@ export const sourcesGetters = { sputniknewscn, ...wallstreetcn, ...xueqiu, + gelonghui, douyin, ...cls, toutiao, diff --git a/server/sources/ithome.ts b/server/sources/ithome.ts index 6269412..951b0d5 100644 --- a/server/sources/ithome.ts +++ b/server/sources/ithome.ts @@ -1,9 +1,8 @@ import * as cheerio from "cheerio" import type { NewsItem } from "@shared/types" -import { $fetch } from "ofetch" export default defineSource(async () => { - const response = await $fetch("https://www.ithome.com/list/") + const response: any = await $fetch("https://www.ithome.com/list/") const $ = cheerio.load(response) const $main = $("#list > div.fl > ul > li") const news: NewsItem[] = [] diff --git a/server/utils/date.ts b/server/utils/date.ts index a9d1c27..79c85e3 100644 --- a/server/utils/date.ts +++ b/server/utils/date.ts @@ -164,7 +164,6 @@ export function parseRelativeDate(date: string) { if (beforeMatches) { matches.push(beforeMatches[1]) // duration 这个插件有 bug,他会重新实现 subtract 这个方法,并且不会处理 weeks。用 ms 就可以调用默认的方法 - // 改成这样之后,月又出问题了,我也是服了 return dayjs().subtract(dayjs.duration(toDurations(matches))).toDate() } @@ -218,5 +217,5 @@ export function parseRelativeDate(date: string) { } } - return date + return new Date() } diff --git a/shared/metadata.ts b/shared/metadata.ts index 7058163..8ff2d05 100644 --- a/shared/metadata.ts +++ b/shared/metadata.ts @@ -19,7 +19,7 @@ const originMetadata: Metadata = { }, finance: { name: "财经", - sources: ["cls-telegraph", "cls-depth", "wallstreetcn", "wallstreetcn-hot", "wallstreetcn-news", "xueqiu-hotstock"], + sources: ["cls-telegraph", "cls-depth", "wallstreetcn", "wallstreetcn-hot", "wallstreetcn-news", "xueqiu-hotstock", "gelonghui"], }, focus: { name: "关注", diff --git a/shared/sources.ts b/shared/sources.ts index a46a787..efd0806 100644 --- a/shared/sources.ts +++ b/shared/sources.ts @@ -157,6 +157,13 @@ export const originSources = { }, }, }, + "gelonghui": { + name: "格隆汇", + color: "blue", + title: "事件", + interval: Time.Realtime, + home: "https://www.gelonghui.com", + }, } as const satisfies Record export const sources = genSources()