zoukankan      html  css  js  c++  java
  • golang 请求接口

    // 调用 
    func CallSearchFillingInfos(UA string,req *request.SearchDocRequest) response.SearchDocResponse {
    	b, err := json.Marshal(req)
    	FillingReq, _ := http.NewRequest(
    		"POST",
    		"https://www.XXX.com/data/api/FinancialNew/SearchFillingInfos",
    		strings.NewReader(string(b)))
    	// 设置user-agent
    	FillingReq.Header.Set("User-Agent", UA)
    	FillingReq.Header.Set("Content-Type","application/json")
    	res, _ := (&http.Client{}).Do(FillingReq)
    	defer res.Body.Close()
    	body, err := ioutil.ReadAll(res.Body)
    	if err != nil {
    		fmt.Println("调用接口异常%v", err.Error())
    	}
    	var SearchDocResponse response.SearchDocResponse
    	if err := json.Unmarshal(body, &SearchDocResponse); err != nil {
    		fmt.Println("json解析错误:",err)
    		return SearchDocResponse
    	}
    	return SearchDocResponse
    }
    

      

  • 相关阅读:
    博客
    欧几里得算法的时间复杂度
    Linux伙伴系统1
    伙伴系统
    websocket
    Colored Sticks POJ
    Repository HDU
    Phone List HDU
    Hat’s Words HDU
    HDU1800 字典树写法
  • 原文地址:https://www.cnblogs.com/sumafan/p/13365979.html
Copyright © 2011-2022 走看看