Get startedGet started for free

Streaming tweets

It's time to stream some tweets! Your task is to create the Streamobject and to filter tweets according to particular keywords. tweepy has been imported for you.

This exercise is part of the course

Intermediate Importing Data in Python

View Course

Exercise instructions

  • Create your Stream object with the credentials given.
  • Filter your Stream variable for the keywords "clinton", "trump", "sanders", and "cruz".

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Store credentials in relevant variables
consumer_key = "nZ6EA0FxZ293SxGNg8g8aP0HM"
consumer_secret = "fJGEodwe3KiKUnsYJC3VRndj7jevVvXbK2D5EiJ2nehafRgA6i"
access_token = "1092294848-aHN7DcRP9B4VMTQIhwqOYiB14YkW92fFO8k8EPy"
access_token_secret = "X4dHmhPfaksHcQ7SCbmZa2oYBBVSD2g8uIHXsp5CTaksx"

# Create your Stream object with credentials
stream = tweepy.Stream(____, ____, ____, ____)

# Filter your Stream variable
stream.filter(____)
Edit and Run Code