Created
October 14, 2020 04:17
-
-
Save jijames/733f483abd166312b14a16300400f580 to your computer and use it in GitHub Desktop.
Python: Count the number of tagged tweets from a username
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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