Go language crawl Twitter

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

1. The first step is to modify the Anaconda library to obtain search_meta_data;

2. Call Anaconda, crawl the search data, slightly


Package Anacondaimport ("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 []tweetsearch_metadata Search_meta_ Data}func (a Twitterapi) Getsearch (queryString string, v URL. Values) (Data search_meta_data, Timeline []tweet, err Error) {var sr Searchresponsev = cleanvalues (v) v.set ("Q", Querystrin g) Response_ch: = Make (chan response) a.queryqueue <-Query{baseurl + "/search/tweets.json", V, &AMP;SR, _get, Response_ ch}//We have to read from the response channel before assigning to timeline//Otherwise This would happen before the RESPO Nses has been writtenresp: = <-response_cherr = Resp.errtimeline = Sr. Statusesdata= Sr. SeArch_metadatareturn data, Timeline, err} 



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.