diff --git a/server/sources/zaobao.ts b/server/sources/zaobao.ts index 35fa409..2242d08 100644 --- a/server/sources/zaobao.ts +++ b/server/sources/zaobao.ts @@ -4,20 +4,19 @@ import iconv from "iconv-lite" import type { NewsItem } from "@shared/types" export default defineSource(async () => { - const response: ArrayBuffer = await myFetch("https://www.kzaobao.com/top.html", { + const response: ArrayBuffer = await myFetch("https://www.zaochenbao.com/realtime/", { responseType: "arrayBuffer", }) - const base = "https://www.kzaobao.com" + const base = "https://www.zaochenbao.com" const utf8String = iconv.decode(Buffer.from(response), "gb2312") const $ = cheerio.load(utf8String) - const $main = $("div[id^='cd0'] tr") + const $main = $("div.list-block>a.item") const news: NewsItem[] = [] $main.each((_, el) => { - const a = $(el).find("h3>a") - // https://www.kzaobao.com/shiju/20241002/170659.html + const a = $(el) const url = a.attr("href") - const title = a.text() - const date = $(el).find("td:nth-child(3)").text() + const title = a.find(".eps")?.text() + const date = a.find(".pdt10")?.text().replace(/-\s/g, " ") if (url && title && date) { news.push({ url: base + url, diff --git a/shared/pre-sources.ts b/shared/pre-sources.ts index d0554db..cb20b20 100644 --- a/shared/pre-sources.ts +++ b/shared/pre-sources.ts @@ -46,6 +46,7 @@ export const originSources = { type: "realtime", column: "world", color: "red", + desc: "来自第三方网站: 早晨报", home: "https://www.zaobao.com", }, "coolapk": { diff --git a/shared/sources.json b/shared/sources.json index 2856f12..7261b23 100644 --- a/shared/sources.json +++ b/shared/sources.json @@ -36,6 +36,7 @@ "zaobao": { "name": "联合早报", "type": "realtime", + "desc": "来自第三方网站: 早晨报", "column": "world", "home": "https://www.zaobao.com", "color": "red",