13.10 Searching Recent Tweets

The Tweepy API method search returns tweets that match a query string. According to the method’s documentation, Twitter maintains its search index only for the previous seven days’ tweets, and a search is not guaranteed to return all matching tweets. Method search calls Twitter’s search/tweets method18, which returns 15 tweets at a time by default, but can return up to 100.

Utility Function print_tweets from tweetutilities.py

For this section, we created a utility function print_tweets that receives the results of a call to API method search and for each tweet displays the user’s screen_name and the tweet’s text. If the tweet ...

Get Intro to Python for Computer Science and Data Science: Learning to Program with AI, Big Data and The Cloud now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.