Skip to content

Instantly share code, notes, and snippets.

@alanhuang122
Created July 20, 2018 21:43
Show Gist options
  • Save alanhuang122/1a084a2978855be8142fc7ce60b6454c to your computer and use it in GitHub Desktop.
Save alanhuang122/1a084a2978855be8142fc7ce60b6454c to your computer and use it in GitHub Desktop.
from collections import Counter
import tweepy
consumer_key = ''
consumer_secret = ''
access_token = ''
access_token_secret = ''
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth, wait_on_rate_limit=True)
tweets = []
for tweet in tweepy.Cursor(api.search, q="4fursuitcrushes1pic", count=100, tweet_mode='extended', include_entities=True).items():
tweets.append(tweet)
base_tweets = [t for t in tweets if not hasattr(t, 'retweeted_status')]
c = Counter()
for tweet in base_tweets:
c.update([user['screen_name'] for user in tweet.entities['user_mentions']])
with open('4fursuitcrushes1pic.txt', 'w') as f:
for entry in c.most_common():
f.write(f'@{entry[0]}: {entry[1]}\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment