Ver Fonte

接口请求结果添加解码

mxs há 7 meses atrás
pai
commit
1ce3c14907
1 ficheiros alterados com 7 adições e 2 exclusões
  1. 7 2
      server.go

+ 7 - 2
server.go

@@ -7,6 +7,7 @@ import (
 	"io/ioutil"
 	qu "jygit.jydev.jianyu360.cn/data_processing/common_utils"
 	"net/http"
+	"net/url"
 	"reflect"
 	be "spider_creator/backend"
 	"time"
@@ -133,7 +134,6 @@ func formatUser(tmp map[string]interface{}) {
 	}
 }
 
-// 获取接口结果
 func getResult(param, result interface{}, route string) {
 	jsonData, err := json.Marshal(param)
 	if err != nil {
@@ -163,7 +163,12 @@ func getResult(param, result interface{}, route string) {
 		qu.Debug("Error reading response body:", err)
 		return
 	}
-	if err := json.Unmarshal(body, &result); err != nil {
+	decodedBody, err := url.QueryUnescape(string(body))
+	if err != nil {
+		qu.Debug("Decoded Body Error:", err)
+		return
+	}
+	if err := json.Unmarshal([]byte(decodedBody), &result); err != nil {
 		qu.Debug("Error unmarshaling response:", err)
 		return
 	}