mirror of
https://github.com/ourongxing/newsnow.git
synced 2025-01-19 03:09:14 +08:00
d7c8a38d88
fixed #20
30 lines
617 B
TypeScript
30 lines
617 B
TypeScript
interface Res {
|
|
data: {
|
|
cards: {
|
|
content: {
|
|
isTop?: boolean
|
|
word: string
|
|
rawUrl: string
|
|
desc?: string
|
|
}[]
|
|
}[]
|
|
}
|
|
}
|
|
|
|
export default defineSource(async () => {
|
|
const rawData: string = await myFetch(`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,
|
|
},
|
|
}
|
|
})
|
|
})
|