1. Learn
  2. /
  3. Courses
  4. /
  5. Importing Data in Python

Connected

Exercise

Streaming tweets

Now that you have set up your authentication credentials, it is time to stream some tweets! In pre-code, we have already defined the Tweet Stream Listener Class, just as Hugo did in the introductory video. You can find the code for the Tweet Stream Listener Class here.

Your task is to create the Stream object and to filter tweets according to particular keywords.

Instructions

100 XP
  • Create your Stream object with authentication by passing to tweepy.Stream() the authentication handler auth and the Stream listener l;
  • To filter Twitter Streams, pass to stream.filter() a list containing the desired keywords 'clinton', 'trump', 'sanders', and 'cruz'.