Skip to content
Snippets Groups Projects
Commit 9739efcb authored by matt01671's avatar matt01671
Browse files

folder for twitter harvesting

parent 0a8f4a34
No related branches found
No related tags found
No related merge requests found
import tweepy
consumer_key =
consumer_secret =
# OAuthHandler instance OAuth 2 Authentication
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
api = tweepy.API(auth)
def get_tweets(query, count = 300):
# empty list to store parsed tweets
tweets = []
target = open("tweets.txt", 'w',encoding="utf-8")
t1 = open("review.txt", 'w',encoding="utf-8")
# call twitter api to fetch tweets
fetched_tweets = api.search(query, count = count)
# Other params, geocode, lang
for tweet in fetched_tweets:
# empty dictionary to store required params of a tweet
parsed_tweet = {}
# saving text of tweet
parsed_tweet['text'] = tweet.text
if "http" not in tweet.text:
line = re.sub("[^A-Za-z]", " ", tweet.text)
target.write(line+"\n")
t1.write(line+"\n")
return tweets
# creating object of TwitterClient Class
# calling function to get tweets
tweets = get_tweets(query =text, count = 20000)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment