mirror of
https://github.com/ourongxing/newsnow.git
synced 2025-01-19 03:09:14 +08:00
feat(source): add solidot.org
This commit is contained in:
parent
28efd23dfa
commit
9420473d41
BIN
public/icons/solidot.png
Normal file
BIN
public/icons/solidot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
1
server/glob.d.ts
vendored
1
server/glob.d.ts
vendored
@ -9,6 +9,7 @@ declare module 'glob:./sources/{*.ts,**/index.ts}' {
|
||||
export const fastbull: typeof import('./sources/fastbull')
|
||||
export const gelonghui: typeof import('./sources/gelonghui')
|
||||
export const ithome: typeof import('./sources/ithome')
|
||||
export const solidot: typeof import('./sources/solidot')
|
||||
export const sputniknewscn: typeof import('./sources/sputniknewscn')
|
||||
export const thepaper: typeof import('./sources/thepaper')
|
||||
export const tieba: typeof import('./sources/tieba')
|
||||
|
26
server/sources/solidot.ts
Normal file
26
server/sources/solidot.ts
Normal file
@ -0,0 +1,26 @@
|
||||
import * as cheerio from "cheerio"
|
||||
import type { NewsItem } from "@shared/types"
|
||||
|
||||
export default defineSource(async () => {
|
||||
const baseURL = "https://www.solidot.org/"
|
||||
const html: any = await $fetch(baseURL)
|
||||
const $ = cheerio.load(html)
|
||||
const $main = $(".block_m")
|
||||
const news: NewsItem[] = []
|
||||
$main.each((_, el) => {
|
||||
const a = $(el).find(".bg_htit a")
|
||||
const url = a.attr("href")
|
||||
const title = a.text()
|
||||
const date_raw = $(el).find(".talk_time").text().match(/发表于(.*?分)/)?.[1]
|
||||
const date = date_raw?.replace(/[年月]/g, "-").replace("时", ":").replace(/[分日]/g, "")
|
||||
if (url && title && date) {
|
||||
news.push({
|
||||
url: baseURL + url,
|
||||
title,
|
||||
id: url,
|
||||
pubDate: parseRelativeDate(date, "Asia/Shanghai").valueOf(),
|
||||
})
|
||||
}
|
||||
})
|
||||
return news
|
||||
})
|
@ -15,7 +15,7 @@ const originMetadata: Metadata = {
|
||||
},
|
||||
tech: {
|
||||
name: "科技",
|
||||
sources: ["ithome", "v2ex", "coolapk"],
|
||||
sources: ["ithome", "v2ex", "coolapk", "solidot"],
|
||||
},
|
||||
finance: {
|
||||
name: "财经",
|
||||
|
@ -185,6 +185,12 @@ export const originSources = {
|
||||
},
|
||||
},
|
||||
},
|
||||
"solidot": {
|
||||
name: "Solidot",
|
||||
color: "sky",
|
||||
home: "https://solidot.org",
|
||||
interval: Time.Slow,
|
||||
},
|
||||
} as const satisfies Record<string, OriginSource>
|
||||
|
||||
export const sources = genSources()
|
||||
|
Loading…
x
Reference in New Issue
Block a user