Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
def get_related_tweets(text_query):
# list to store tweets
tweets_list = []
# no of tweets
count = 50
try:
# Pulling individual tweets from query
for tweet in api.search(q=text_query, count=count):
print(tweet.text)
# Adding to list that contains all tweets
tweets_list.append({'created_at': tweet.created_at,
'tweet_id': tweet.id,
'tweet_text': tweet.text})
return pd.DataFrame.from_dict(tweets_list)
except BaseException as e:
print('failed on_status,', str(e))
time.sleep(3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment