Skip to content

Instantly share code, notes, and snippets.

@zdepablo
Created March 3, 2014 15:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zdepablo/9327508 to your computer and use it in GitHub Desktop.
Save zdepablo/9327508 to your computer and use it in GitHub Desktop.
Search tweets using TwitterAPI
from TwitterAPI import TwitterAPI
# Go to http://dev.twitter.com and create an app.
# The consumer key and secret will be generated for you after
consumer_key = <consumer-key>
consumer_secret = <consumer-secret>
# After the step above, you will be redirected to your app's page.
# Create an access token under the the "Your access token" section
access_token_key = <access-token-key>
access_token_secret = <access-token-secret>
# Create a Twitter client
twitter = TwitterAPI(consumer_key, consumer_secret, access_token_key, access_token_secret)
query = {'q' : 'Top Chef', 'lang' : 'es', 'count': 100}
results = twitter.request('search/tweets', query )
for tweet in results.get_iterator():
print tweet['id'], tweet['text']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment