Novice programmer here seeking help.
I already set up my code to my requirements to use the Twitter’s premium API.
SEARCH_TERM = '#AAPL OR #FB OR #KO OR #ABT OR #PEPCO'
PRODUCT = 'fullarchive'
LABEL = 'my_label'
r = api.request('tweets/search/%s/:%s' % (PRODUCT, LABEL),
{'query':SEARCH_TERM, 'fromDate':201501010000, 'toDate':201812310000})
However, when I run it I obtain the maximum number of tweets per search which is 500.
My question is should I add to the query maxResults = 500? And how do I use the next parameter to keep the code running until all the tweets that correspond to my query are obtained?
2
Answers
Use the count variable in a raw_query, for example:
To up the results from the default of 100 to 500, yes, add
maxResults
to the query like this:You can make successive queries to get more results by using the
next
parameter. But, even easier, you can let TwitterAPI do this for you by using theTwitterPager
class. Here is an example:This example will keep making successive requests with the
next
parameter until no tweets can be downloaded.