newsnow/server/sources/douyin.ts

28 lines
739 B
TypeScript
Raw Permalink Normal View History

2024-10-13 11:39:28 +08:00
interface Res {
2024-10-21 01:38:58 +08:00
data: {
word_list: {
2024-10-13 11:39:28 +08:00
sentence_id: string
word: string
event_time: string
hot_value: string
}[]
}
}
export default defineSource(async () => {
const url = "https://www.douyin.com/aweme/v1/web/hot/search/list/?device_platform=webapp&aid=6383&channel=channel_pc_web&detail_list=1"
2024-10-21 17:00:51 +08:00
const cookie = (await $fetch.raw("https://www.douyin.com/passport/general/login_guiding_strategy/?aid=6383")).headers.getSetCookie()
const res: Res = await myFetch(url, {
2024-10-13 11:39:28 +08:00
headers: {
2024-10-21 17:00:51 +08:00
cookie: cookie.join("; "),
2024-10-13 11:39:28 +08:00
},
})
2024-10-25 03:06:03 +08:00
return res.data.word_list.map((k) => {
return {
id: k.sentence_id,
title: k.word,
url: `https://www.douyin.com/hot/${k.sentence_id}`,
}
})
2024-10-13 11:39:28 +08:00
})