Skip to content

Instantly share code, notes, and snippets.

@hancush
Last active September 8, 2015 01:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hancush/fffdd6b1d7010cf9249a to your computer and use it in GitHub Desktop.
Save hancush/fffdd6b1d7010cf9249a to your computer and use it in GitHub Desktop.
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