Skip to content

Commit

Permalink
baidu: 对要查询的内容进行URI编码 (#866)
Browse files Browse the repository at this point in the history
  • Loading branch information
EatHatsuneShallots committed Mar 4, 2024
1 parent 6f2c9f7 commit 6c20f22
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions plugin/baidu/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package baidu
import (
"encoding/json"
"fmt"
"net/url"

"github.com/FloatTech/floatbox/web"
ctrl "github.com/FloatTech/zbpctrl"
Expand Down Expand Up @@ -37,9 +38,9 @@ func init() { // 主函数
var err error
switch ctx.State["regex_matched"].([]string)[1] {
case "百度", "百科":
es, err = web.GetData(fmt.Sprintf(duURL, key, ctx.State["regex_matched"].([]string)[2])) // 将网站返回结果赋值
es, err = web.GetData(fmt.Sprintf(duURL, key, url.QueryEscape(ctx.State["regex_matched"].([]string)[2]))) // 将网站返回结果赋值
case "wiki", "维基":
es, err = web.GetData(fmt.Sprintf(wikiURL, key, ctx.State["regex_matched"].([]string)[2])) // 将网站返回结果赋值
es, err = web.GetData(fmt.Sprintf(wikiURL, key, url.QueryEscape(ctx.State["regex_matched"].([]string)[2]))) // 将网站返回结果赋值
}
if err != nil {
ctx.SendChain(message.Text("出现错误捏:", err))
Expand Down

0 comments on commit 6c20f22

Please sign in to comment.