Skip to content

Commit 013fd1e

Browse files
author
chaozhu
committed
update: baidu hotword api
1 parent 9b0bfe0 commit 013fd1e

3 files changed

Lines changed: 13 additions & 13 deletions

File tree

finder.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,24 @@ const (
1111
KindHotword = "hotword"
1212
KindSuggestion = "suggestion"
1313

14-
VERSION = "v1.0.12"
14+
VERSION = "v1.0.14"
1515
)
1616

1717
var (
1818
once sync.Once
1919
instance Engine
2020
)
2121

22-
/////////////////////////////
22+
// ///////////////////////////
2323
// finder interface
24-
/////////////////////////////
24+
// ///////////////////////////
2525
type Finder interface {
2626
Close()
2727
}
2828

29-
/////////////////////////////
29+
// ///////////////////////////
3030
// finder engine
31-
/////////////////////////////
31+
// ///////////////////////////
3232
// Engine is default finder implement.
3333
type Engine struct {
3434
finderMap map[string]Finder

hotword.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const (
1818
HotWordSm = "sm"
1919

2020
// Url
21-
BaiduHotWordsUrl = "http://top.baidu.com/mobile_v2/buzz/hotspot"
21+
BaiduHotWordsUrl = "https://top.baidu.com/api/board?platform=wise&tab=realtime&tag=%7B%7D"
2222
SoHotWordsUrl = "https://m.so.com/home/data?types=Hotwords&fmt=json"
2323
SoGouHotWordsUrl = "https://wap.sogou.com/data/hotwords/sogou_app.js"
2424
TouTiaoHotWordsUrl = "https://i.snssdk.com/hot-event/hot-board/?count=50&tab_name=stream&origin=hot_board"
@@ -35,9 +35,9 @@ const (
3535
HotWordHttpTimeout = 60
3636
)
3737

38-
/////////////////////////////
38+
// ///////////////////////////
3939
// HotWord Result
40-
/////////////////////////////
40+
// ///////////////////////////
4141
type HotWordResult struct {
4242
Keyword string
4343
Weight int
@@ -49,9 +49,9 @@ func (wr *HotWordResult) Json() string {
4949
return string(body)
5050
}
5151

52-
/////////////////////////////
52+
// ///////////////////////////
5353
// HotWord Finder
54-
/////////////////////////////
54+
// ///////////////////////////
5555
type HotWordFinder struct {
5656
Provider string
5757
From string

hotword_baidu.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ func BaiduHotWordFind(hwf *HotWordFinder, from string, suggestUrl string) ([]*Ho
3636
}
3737

3838
// format json
39-
hotwords := result.Get("result.topwords")
39+
hotwords := result.Get("data.cards.#[component=hotList].content")
4040
for _, hotword := range hotwords.Array() {
41-
keyword := hotword.Get("keyword").String()
42-
weight, _ := strconv.Atoi(hotword.Get("searches").String())
41+
keyword := hotword.Get("word").String()
42+
weight, _ := strconv.Atoi(hotword.Get("hotScore").String())
4343
suggestUrl := hwf.GetSuggestUrl(keyword, from, suggestUrl)
4444

4545
hwr := &HotWordResult{

0 commit comments

Comments
 (0)