Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. import tweepy
  2. import csv
  3.  
  4. # assuming twitter_authentication.py contains each of the 4 oauth elements (1 per line)
  5. from twitter_authentication import API_KEY, API_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET
  6.  
  7. auth = tweepy.OAuthHandler(API_KEY, API_SECRET)
  8. auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
  9. api = tweepy.API(auth,wait_on_rate_limit=True)
  10.  
  11. csvFile = open('antivacc.csv', 'a')
  12. #Use csv Writer
  13. csvWriter = csv.writer(csvFile)
  14.  
  15. for tweet in tweepy.Cursor(api.search,q="#antivaccine",count=100,
  16. lang="en",
  17. since="2019-04-01",
  18. until="2019-06-01").items():
  19. print (tweet.created_at, tweet.text)
  20. csvWriter.writerow([tweet.created_at, tweet.text.encode('utf-8')])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement