IniziaInizia gratis

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.

Questo esercizio fa parte del corso

Intermediate Importing Data in Python

Visualizza il corso

Istruzioni dell'esercizio

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

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

# 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(____)
Modifica ed esegui il codice