1. 第一步修改anaconda库, 以获取Search_meta_data ;
2. 调用anaconda, 抓取search数据,略
package anaconda import ( "net/url" ) type Search_meta_data struct { Completed_in float32 `json:"completed_in"` Max_id int64 `json:"max_id"` Max_id_str string `json:"max_id_str"` Next_results string `json:"next_results"` Query string `json:"query"` Refresh_url string `json:"refresh_url"` Count int `json:"count"` Since_id int `json:"since_id"` Since_id_str string `json:"since_id_str"` } type searchResponse struct { Statuses []Tweet Search_metadata Search_meta_data } func (a TwitterApi) GetSearch(queryString string, v url.Values) (data Search_meta_data, timeline []Tweet, err error) { var sr searchResponse v = cleanValues(v) v.Set("q", queryString) response_ch := make(chan response) a.queryQueue <- query{BaseUrl + "/search/tweets.json", v, &sr, _GET, response_ch} // We have to read from the response channel before assigning to timeline // Otherwise this will happen before the responses have been written resp := <-response_ch err = resp.err timeline = sr.Statuses data= sr.Search_metadata return data, timeline, err }
有疑问加站长微信联系(非本文作者)