Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- """
- Created on Mon May 21 23:41:54 2018
- @author: zwang
- """
- import tweepy
- def getAuthData():
- import csv
- with open('/Users/zwang/BPI/authdata.csv', 'r') as f:
- reader = csv.reader(f)
- your_list = list(reader)
- authdata = {}
- for element in your_list:
- authdata[element[0]] = element[1]
- print(authdata)
- return authdata
- def getTweepyData(tweet_id):
- CONSUMER_KEY = authdata['CONSUMER_KEY']
- CONSUMER_SECRET = authdata['CONSUMER_SECRET']
- OAUTH_TOKEN = authdata['OAUTH_TOKEN']
- OAUTH_TOKEN_SECRET = authdata['OAUTH_TOKEN_SECRET']
- auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
- auth.set_access_token(OAUTH_TOKEN,OAUTH_TOKEN_SECRET)
- api = tweepy.API(auth)
- tweet = api.get_status(tweet_id)
- retweet_count = tweet.retweet_count
- favorite_count = tweet.favorite_count
- return {'retweet':retweet_count, 'favorite':favorite_count }
- authdata = getAuthData()
- getTweepyData("957578733053009920")
Add Comment
Please, Sign In to add comment