Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tweepy
- import csv
- # assuming twitter_authentication.py contains each of the 4 oauth elements (1 per line)
- from twitter_authentication import API_KEY, API_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET
- auth = tweepy.OAuthHandler(API_KEY, API_SECRET)
- auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
- api = tweepy.API(auth,wait_on_rate_limit=True)
- csvFile = open('antivacc.csv', 'a')
- #Use csv Writer
- csvWriter = csv.writer(csvFile)
- for tweet in tweepy.Cursor(api.search,q="#antivaccine",count=100,
- lang="en",
- since="2019-04-01",
- until="2019-06-01").items():
- print (tweet.created_at, tweet.text)
- csvWriter.writerow([tweet.created_at, tweet.text.encode('utf-8')])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement