Skip to content

Instantly share code, notes, and snippets.

@konrad
Last active May 6, 2016 19:50
Show Gist options
  • Save konrad/d6f0ab643b2e4407d5d6 to your computer and use it in GitHub Desktop.
Save konrad/d6f0ab643b2e4407d5d6 to your computer and use it in GitHub Desktop.
An example how to get all tweets containing a hashtag (here #BOSC2015) and storing each tweets as JSON string.
from TwitterSearch import *
import json
try:
tso = TwitterSearchOrder()
tso.set_keywords(['#BOSC2015'])
# Please replace with your credentials
ts = TwitterSearch(
consumer_key='REPLACE_ME',
consumer_secret='REPLACE_ME',
access_token='REPLACE_ME',
access_token_secret='REPLACE_ME'
)
for tweet in ts.search_tweets_iterable(tso):
print(json.dumps(tweet))
except TwitterSearchException as e:
print(e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment