Update nbnhhsh.go

This commit is contained in:
源文雨 2021-09-26 10:15:22 +08:00 committed by GitHub
parent c724be743d
commit 83199cf3aa

View File

@ -23,9 +23,11 @@ func init() {
func getValue(text string) []string {
urlValues := url.Values{}
urlValues.Add("text", text)
resp, _ := http.PostForm("https://lab.magiconch.com/api/nbnhhsh/guess", urlValues)
body, _ := ioutil.ReadAll(resp.Body)
resp.Close()
resp, err := http.PostForm("https://lab.magiconch.com/api/nbnhhsh/guess", urlValues)
if err == nil {
body, err := ioutil.ReadAll(resp.Body)
if err == nil {
resp.Body.Close()
json := gjson.ParseBytes(body)
res := make([]string, 0)
var jsonPath string
@ -39,3 +41,7 @@ func getValue(text string) []string {
}
return res
}
return []string{err.Error()}
}
return []string{err.Error()}
}