Skip to content

Instantly share code, notes, and snippets.

@jijames
Created October 14, 2020 04:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jijames/733f483abd166312b14a16300400f580 to your computer and use it in GitHub Desktop.
Save jijames/733f483abd166312b14a16300400f580 to your computer and use it in GitHub Desktop.
Python: Count the number of tagged tweets from a username
import os, sys
import tweepy as tw
from collections import Counter
from dateutil.parser import parse
search_words = "#MagnetWeeklyCTF -filter:retweets" # Use -filter:retweets
date_since = "2020-09-01"
consumer_key= ''
consumer_secret= ''
access_token= ''
access_token_secret= ''
auth = tw.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tw.API(auth, wait_on_rate_limit=True)
tweets = tw.Cursor(api.search,
q=search_words,
since=date_since).items()
authors = []
for tweet in tweets:
authors.append(tweet.user.screen_name)
counts = Counter(authors)
print(counts)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment