Last active
September 8, 2015 01:17
-
-
Save hancush/fffdd6b1d7010cf9249a to your computer and use it in GitHub Desktop.
This file contains hidden or 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 tweepy | |
from config import * | |
import requests | |
requests.packages.urllib3.disable_warnings() | |
auth = tweepy.OAuthHandler(ckey, csecret) | |
twitter = tweepy.API(auth) | |
query = str(raw_input("what's yr joke? ")) | |
results = tweepy.Cursor(twitter.search, q=query).items(101) | |
counter = 0 | |
for tweet in results: | |
text = tweet.text | |
details = tweet._json | |
if counter < 100: | |
counter += 1 | |
print "joke #{0}: \"{1}\" by @{2}.".format( | |
counter, | |
text.encode('ascii', 'ignore'), | |
details['user']['screen_name'] | |
) | |
else: | |
break | |
if counter == 0: | |
print "wow, that's a new one. go ahead, tweet your joke! :)" | |
elif counter < 100: | |
print "{0} people have already tweeted your joke. :(".format(counter) | |
else: | |
print "so many people have tweeted your joke that i had to abort the script. :((((" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment