Skip to content

Instantly share code, notes, and snippets.

@dgnsrekt
Last active March 6, 2019 00:51
Show Gist options
  • Save dgnsrekt/b36c3888487de2745f2c86583f22b530 to your computer and use it in GitHub Desktop.
Save dgnsrekt/b36c3888487de2745f2c86583f22b530 to your computer and use it in GitHub Desktop.
gets the retweets and likes from tweets made in the last two days.
import tweepy
from time import sleep
from datetime import datetime
import pytz
CONSUMER_KEY = ""
CONSUMER_SECRET = ""
ACCESS_KEY = ""
ACCESS_SECRET = ""
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)
api = tweepy.API(auth)
utc = pytz.utc
now = datetime.now(utc)
today = datetime(now.year, now.month, now.day - 1, tzinfo=utc)
for i, status in enumerate(tweepy.Cursor(api.user_timeline).items()):
if utc.localize(status.created_at) < today:
print(status)
break
print(
i,
status.id,
status.retweet_count,
status.created_at,
status.retweeted,
status.retweet_count,
status.favorited,
status.favorite_count,
status.entities,
status.text,
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment