mirror of
https://github.com/ourongxing/newsnow.git
synced 2025-01-31 19:08:05 +08:00
47767a6d62
close #13
30 lines
616 B
TypeScript
30 lines
616 B
TypeScript
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,
|
|
},
|
|
}
|
|
})
|
|
})
|