Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.