Guest User

Untitled

a guest
May 26th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. """
  4. Created on Mon May 21 23:41:54 2018
  5.  
  6. @author: zwang
  7. """
  8.  
  9. import tweepy
  10.  
  11. def getAuthData():
  12. import csv
  13. with open('/Users/zwang/BPI/authdata.csv', 'r') as f:
  14. reader = csv.reader(f)
  15. your_list = list(reader)
  16.  
  17. authdata = {}
  18. for element in your_list:
  19. authdata[element[0]] = element[1]
  20. print(authdata)
  21.  
  22. return authdata
  23.  
  24.  
  25. def getTweepyData(tweet_id):
  26. CONSUMER_KEY = authdata['CONSUMER_KEY']
  27. CONSUMER_SECRET = authdata['CONSUMER_SECRET']
  28. OAUTH_TOKEN = authdata['OAUTH_TOKEN']
  29. OAUTH_TOKEN_SECRET = authdata['OAUTH_TOKEN_SECRET']
  30.  
  31. auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
  32. auth.set_access_token(OAUTH_TOKEN,OAUTH_TOKEN_SECRET)
  33. api = tweepy.API(auth)
  34.  
  35. tweet = api.get_status(tweet_id)
  36. retweet_count = tweet.retweet_count
  37. favorite_count = tweet.favorite_count
  38.  
  39. return {'retweet':retweet_count, 'favorite':favorite_count }
  40.  
  41. authdata = getAuthData()
  42. getTweepyData("957578733053009920")
Add Comment
Please, Sign In to add comment