Skip to content

Commit fc57acf

Browse files
committed
fix: weibo
1 parent 681d137 commit fc57acf

1 file changed

Lines changed: 130 additions & 34 deletions

File tree

server/sources/weibo.ts

Lines changed: 130 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,144 @@
1-
interface Res {
2-
ok: number // 1 is ok
3-
data: {
4-
realtime:
5-
{
6-
num: number // 看上去是个 id
7-
emoticon: string
8-
icon?: string // 热,新 icon url
9-
icon_width: number
10-
icon_height: number
11-
is_ad?: number // 1
12-
note: string
13-
small_icon_desc: string
14-
icon_desc?: string // 如果是 荐 ,就是广告
15-
topic_flag: number
16-
icon_desc_color: string
17-
flag: number
18-
word_scheme: string
19-
small_icon_desc_color: string
20-
realpos: number
21-
label_name: string
22-
word: string // 热搜词
23-
rank: number
24-
}[]
25-
}
1+
export interface Root {
2+
ok: number
3+
data: Data
4+
}
5+
6+
export interface Data {
7+
mapi: any[]
8+
cards: Card[]
9+
cardlistInfo: CardlistInfo
10+
scheme: string
11+
showAppTips: number
12+
}
13+
14+
export interface Card {
15+
card_group: CardGroup[]
16+
card_type: number
17+
show_type: number
18+
itemid?: string
19+
title?: string
20+
}
21+
22+
export interface CardGroup {
23+
actionlog?: Actionlog
24+
card_type: number
25+
pic?: string
26+
itemid?: string
27+
icon?: string
28+
icon_width?: number
29+
icon_height?: number
30+
desc?: string
31+
scheme: string
32+
desc_extr: any
33+
promotion?: Promotion
34+
display_arrow?: number
35+
show_type?: number
36+
title?: string
37+
is_show_arrow?: number
38+
left_tag_img?: string
39+
sub_title?: string
40+
}
41+
42+
export interface Actionlog {
43+
luicode: string
44+
lfid: string
45+
uicode: string
46+
act_code: number
47+
act_type: number
48+
fid: string
49+
ext: string
50+
}
51+
52+
export interface Promotion {
53+
monitor_url: MonitorUrl[]
54+
}
55+
56+
export interface MonitorUrl {
57+
third_party_click: string
58+
third_party_show: string
59+
type: string
60+
monitor_name?: string
61+
}
62+
63+
export interface CardlistInfo {
64+
select_id: string
65+
title_top: string
66+
show_style: number
67+
starttime: number
68+
can_shared: number
69+
v_p: string
70+
containerid: string
71+
page_type: string
72+
nick: string
73+
cardlist_head_cards: CardlistHeadCard[]
74+
enable_load_imge_scrolling: number
75+
page_title: string
76+
search_request_id: string
77+
load_more_threshold: number
78+
pagesize: number
79+
page_common_ext: string
80+
cardlist_menus: any[]
81+
total: number
82+
headbg_animation: string
83+
page_size: number
84+
page: any
85+
}
86+
87+
export interface CardlistHeadCard {
88+
title_top?: string
89+
show_menu: boolean
90+
head_type_name: string
91+
head_type: number
92+
head_data?: HeadData
93+
channel_list?: ChannelList[]
94+
}
95+
96+
export interface HeadData {
97+
cover_url: string
98+
show_navi_mask: boolean
99+
show_title: boolean
100+
data_type: number
101+
scheme: string
102+
}
103+
104+
export interface ChannelList {
105+
actionlog: Actionlog2
106+
scheme: string
107+
containerid: string
108+
name: string
109+
default_add: number
110+
id: number
111+
must_show: number
112+
replaced_name?: string
113+
}
114+
115+
export interface Actionlog2 {
116+
luicode: string
117+
lfid: string
118+
uicode: string
119+
act_code: number
120+
act_type: number
121+
fid: string
122+
ext: string
26123
}
27124

28125
export default defineSource(async () => {
29-
const url = "https://weibo.com/ajax/side/hotSearch"
30-
const res: Res = await myFetch(url)
31-
return res.data.realtime
32-
.filter(k => !k.is_ad)
126+
const url = "https://m.weibo.cn/api/container/getIndex?containerid=106003type%3D25%26t%3D3%26disable_hot%3D1%26filter_type%3Drealtimehot"
127+
const res: Root = await myFetch(url)
128+
return res.data.cards[0].card_group
129+
.filter((k, i) => i !== 0 && k.desc && !k.actionlog?.ext.includes("ads_word"))
33130
.map((k) => {
34-
const keyword = k.word_scheme ? k.word_scheme : `#${k.word}#`
35131
return {
36-
id: k.word,
37-
title: k.word,
132+
id: k.desc!,
133+
title: k.desc!,
38134
extra: {
39135
icon: k.icon && {
40136
url: proxyPicture(k.icon),
41137
scale: 1.5,
42138
},
43139
},
44-
url: `https://s.weibo.com/weibo?q=${encodeURIComponent(keyword)}`,
45-
mobileUrl: `https://m.weibo.cn/search?containerid=231522type%3D1%26q%3D${encodeURIComponent(keyword)}&_T_WM=16922097837&v_p=42`,
140+
url: `https://s.weibo.com/weibo?q=${encodeURIComponent(`#${k.desc}#`)}`,
141+
mobileUrl: k.scheme,
46142
}
47143
})
48144
})

0 commit comments

Comments
 (0)