You need to get all the tweets on a specific topic (for example, containing a link to my resource). For this code is written from the series:

api = tw_oauth('./auth.k') coursor = tweepy.Cursor(api.search, q='site.ru', count = 20) for tweet in coursor.items(): ... 

(tried to specify the number of tweets of interest in items (20), does not affect the result). (tried to specify since_id equal to the last received tweet, or even older, but also not affected)

However, at the output I get exactly 7 tweets. Questions 2:

  1. How to get more than 7 tweets at a time?
  2. How to get tweets older (and not younger) of a certain time or ID? (Judging by the dock since_id allows you to receive YOUNG tweets, the ID of which is MORE specified)

    1 answer 1

    For some search queries, the twitter API may give less results than a search on the site through a browser (why I don’t know why). That is why I received only 7 results yesterday.

    If the request can give more requests through the API than specified in the count parameter, the answer to question 1:

     def limit_handled(cursor): while True: try: yield cursor.next() except tweepy.RateLimitError: time.sleep(15 * 60) for tweet in limit_handled(tweepy.Cursor(api.search, q='site.ru', count = 20).items()): print (tweet.id) 

    Answer to question 2: No, it is impossible. The Twitter API documentation says that only records from the last 7 days are available for search. Although in practice it is possible to obtain data for 10.

    • however, question 2 remains relevant. Ie if in the process of parsing the tweeter to collect N messages and rest against the daily limit, it is not clear how to continue from the same place the next day. The parameter page = 2 in the cursor results in a 400 response error from the API. - Alexey Zadoyny
    • The experiment showed that the twitter API gives data in about the last 10 days. For this, a query of the form 'site.ru until: 2016-09-20' was used. Playing the date you can get some results before September 19 and 20 (today is 29). For 18 it is impossible to get ANYTHING. = ( - Alexey Zadoynyj