update tianyancha

master
李光春 2 years ago
parent 53fb10fb1e
commit 8755bcb726

@ -1,10 +1,11 @@
package tianyancha package tianyancha
import ( import (
"encoding/json"
"net/http" "net/http"
) )
type EquityHumanIndexNodeResult struct { type EquityHumanIndexNodeResponse struct {
IsLogin int `json:"isLogin"` IsLogin int `json:"isLogin"`
Message string `json:"message"` Message string `json:"message"`
Special string `json:"special"` Special string `json:"special"`
@ -12,10 +13,23 @@ type EquityHumanIndexNodeResult struct {
VipMessage string `json:"vipMessage"` VipMessage string `json:"vipMessage"`
} }
func (app *App) EquityHumanIndexNode(notMustParams ...Params) (body []byte, err error) { type EquityHumanIndexNodeResult struct {
Result EquityHumanIndexNodeResponse // 结果
Body []byte // 内容
Err error // 错误
}
func NewEquityHumanIndexNodeResult(result EquityHumanIndexNodeResponse, body []byte, err error) *EquityHumanIndexNodeResult {
return &EquityHumanIndexNodeResult{Result: result, Body: body, Err: err}
}
func (app *App) EquityHumanIndexNode(notMustParams ...Params) *EquityHumanIndexNodeResult {
// 参数 // 参数
params := app.NewParamsWith(notMustParams...) params := app.NewParamsWith(notMustParams...)
// 请求 // 请求
body, err = app.request("https://capi.tianyancha.com/cloud-equity-provider/v4/equity/humanIndexnode.json", params, http.MethodGet) body, err := app.request("https://capi.tianyancha.com/cloud-equity-provider/v4/equity/humanIndexnode.json", params, http.MethodGet)
return body, err // 定义
var response EquityHumanIndexNodeResponse
err = json.Unmarshal(body, &response)
return NewEquityHumanIndexNodeResult(response, body, err)
} }

@ -1,11 +1,12 @@
package tianyancha package tianyancha
import ( import (
"encoding/json"
"fmt" "fmt"
"net/http" "net/http"
) )
type SearchHumanSuggestResult struct { type SearchHumanSuggestResponse struct {
Data struct { Data struct {
Id int `json:"id"` Id int `json:"id"`
HumanName interface{} `json:"humanName"` HumanName interface{} `json:"humanName"`
@ -44,7 +45,20 @@ type SearchHumanSuggestResult struct {
State string `json:"state"` State string `json:"state"`
} }
func (app *App) SearchHumanSuggest(key string) (body []byte, err error) { type SearchHumanSuggestResult struct {
body, err = app.request(fmt.Sprintf("https://www.tianyancha.com/search/humanSuggest.json?key=%s", key), map[string]interface{}{}, http.MethodGet) Result SearchHumanSuggestResponse // 结果
return body, err Body []byte // 内容
Err error // 错误
}
func NewSearchHumanSuggestResult(result SearchHumanSuggestResponse, body []byte, err error) *SearchHumanSuggestResult {
return &SearchHumanSuggestResult{Result: result, Body: body, Err: err}
}
func (app *App) SearchHumanSuggest(key string) *SearchHumanSuggestResult {
body, err := app.request(fmt.Sprintf("https://www.tianyancha.com/search/humanSuggest.json?key=%s", key), map[string]interface{}{}, http.MethodGet)
// 定义
var response SearchHumanSuggestResponse
err = json.Unmarshal(body, &response)
return NewSearchHumanSuggestResult(response, body, err)
} }
Loading…
Cancel
Save