Created
September 11, 2015 01:14
-
-
Save anonymous/703ac9030d7c6724583c to your computer and use it in GitHub Desktop.
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
from datetime import datetime, timedelta | |
import tweepy | |
from config import * | |
import requests | |
requests.packages.urllib3.disable_warnings() | |
OAUTH_KEYS = (ckey, csecret, atoken, asecret) | |
auth = tweepy.OAuthHandler(ckey, csecret) | |
twitter = tweepy.API(auth) | |
timeline = tweepy.Cursor(twitter.list_timeline, list_id=211679718).items(999) | |
count = 0 | |
now = datetime.now().strftime('%H:%M:%S') | |
cutoff = (datetime.now() - timedelta(hours=1)).strftime('%H:%M:%S') | |
for tweet in timeline: | |
count += 1 | |
data = tweet._json | |
# format created_at string to datetime # | |
raw_time = datetime.strptime(data['created_at'], '%a %b %d %H:%M:%S +0000 %Y') | |
# convert created_at from UTC to CDT (my local time) # | |
adjust_time = raw_time - timedelta(hours=5) | |
# reformat adjusted time to hour:minute:second as string # | |
time = adjust_time.strftime('%H:%M:%S') | |
if time > cutoff: | |
print count, time, tweet.text | |
else: | |
print count, time, tweet.text, time > cutoff | |
break | |
print "Now: ", now | |
print "Cutoff ", cutoff |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment