mirror of
https://github.com/ourongxing/newsnow.git
synced 2025-01-19 03:09:14 +08:00
parent
655204a14f
commit
47767a6d62
1
server/glob.d.ts
vendored
1
server/glob.d.ts
vendored
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
declare module 'glob:./sources/{*.ts,**/index.ts}' {
|
declare module 'glob:./sources/{*.ts,**/index.ts}' {
|
||||||
export const _36kr: typeof import('./sources/_36kr')
|
export const _36kr: typeof import('./sources/_36kr')
|
||||||
|
export const baidu: typeof import('./sources/baidu')
|
||||||
export const bilibili: typeof import('./sources/bilibili')
|
export const bilibili: typeof import('./sources/bilibili')
|
||||||
export const cankaoxiaoxi: typeof import('./sources/cankaoxiaoxi')
|
export const cankaoxiaoxi: typeof import('./sources/cankaoxiaoxi')
|
||||||
export const cls: typeof import('./sources/cls/index')
|
export const cls: typeof import('./sources/cls/index')
|
||||||
|
29
server/sources/baidu.ts
Normal file
29
server/sources/baidu.ts
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
interface Res {
|
||||||
|
data: {
|
||||||
|
cards: {
|
||||||
|
content: {
|
||||||
|
isTop?: boolean
|
||||||
|
word: string
|
||||||
|
rawUrl: string
|
||||||
|
desc?: string
|
||||||
|
}[]
|
||||||
|
}[]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default defineSource(async () => {
|
||||||
|
const rawData: string = await $fetch(`https://top.baidu.com/board?tab=realtime`)
|
||||||
|
const jsonStr = (rawData as string).match(/<!--s-data:(.*?)-->/s)
|
||||||
|
const data: Res = JSON.parse(jsonStr![1])
|
||||||
|
|
||||||
|
return data.data.cards[0].content.filter(k => !k.isTop).map((k) => {
|
||||||
|
return {
|
||||||
|
id: k.rawUrl,
|
||||||
|
title: k.word,
|
||||||
|
url: k.rawUrl,
|
||||||
|
extra: {
|
||||||
|
hover: k.desc,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
@ -42,7 +42,7 @@ export default defineSource(async () => {
|
|||||||
// 获取热榜列表数据
|
// 获取热榜列表数据
|
||||||
const hotRankData = data.defaultClient[hotRankId] as HotRankData
|
const hotRankData = data.defaultClient[hotRankId] as HotRankData
|
||||||
// 转换数据格式
|
// 转换数据格式
|
||||||
return hotRankData.items.map((item) => {
|
return hotRankData.items.filter(k => data.defaultClient[k.id].tagType !== "置顶").map((item) => {
|
||||||
// 从id中提取实际的热搜词
|
// 从id中提取实际的热搜词
|
||||||
const hotSearchWord = item.id.replace("VisionHotRankItem:", "")
|
const hotSearchWord = item.id.replace("VisionHotRankItem:", "")
|
||||||
|
|
||||||
|
@ -254,7 +254,7 @@ export const originSources = {
|
|||||||
column: "china",
|
column: "china",
|
||||||
color: "orange",
|
color: "orange",
|
||||||
// cloudflare pages cannot access
|
// cloudflare pages cannot access
|
||||||
// disable: true,
|
disable: true,
|
||||||
home: "https://www.kuaishou.com",
|
home: "https://www.kuaishou.com",
|
||||||
},
|
},
|
||||||
"kaopu": {
|
"kaopu": {
|
||||||
@ -272,6 +272,13 @@ export const originSources = {
|
|||||||
type: "realtime",
|
type: "realtime",
|
||||||
home: "https://www.jin10.com",
|
home: "https://www.jin10.com",
|
||||||
},
|
},
|
||||||
|
"baidu": {
|
||||||
|
name: "百度热搜",
|
||||||
|
column: "china",
|
||||||
|
color: "blue",
|
||||||
|
type: "hottest",
|
||||||
|
home: "https://www.baidu.com",
|
||||||
|
},
|
||||||
} as const satisfies Record<string, OriginSource>
|
} as const satisfies Record<string, OriginSource>
|
||||||
|
|
||||||
export const sources = genSources()
|
export const sources = genSources()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user