I’m looking into the Twitter Search API, and apparently, it has a count parameter that determines “The number of tweets to return per page, up to a maximum of 100.” What does “per page” mean, if I’m for example running a python script like this:
import twitter #python-twitter package
api = twitter.Api(consumer_key="mykey",
consumer_secret="mysecret",
access_token_key="myaccess",
access_token_secret="myaccesssecret")
results = api.GetSearch(raw_query="q=%23myHashtag&geocode=59.347937,18.072433,5km")
print(len(results))
This will only give me 15 tweets in results. I want more, preferably all tweets, if possible. So what should I do? Is there a “next page” option? Can’t I just specify the search query in a way that gives me all tweets at once? Or if the number of tweets is too large, some maximum number of tweets?
2
Answers
Tweepy has a
Cursor
object that works like this:You can find more info in the Tweepy Cursor docs.
With TwitterAPI you would access pages this way:
A complete example is here: https://github.com/geduldig/TwitterAPI/blob/master/examples/page_tweets.py