Created
June 25, 2011 10:49
-
-
Save hj91/1046366 to your computer and use it in GitHub Desktop.
Example of using Twitter api with Tweepy library
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
#!/usr/bin/env python | |
#(c) Harshad Joshi, 2011 | |
#firewalrus [AT] gmail DOT com | |
import sys | |
import tweepy | |
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) | |
def start(): | |
a = raw_input ("\n Enter mentions or home or exit to quit :") | |
if (a == "exit"): | |
sys.exit(0) | |
if (a == 'mentions'): | |
mymentions = api.mentions() | |
for tweet in mymentions: | |
d = str(unicode(tweet.text).encode("utf-8"))+" >> "+str(unicode(tweet.user.screen_name).encode("utf-8")) | |
print d | |
else: | |
if (a.lower() == 'home'): | |
home = api.home_timeline() | |
for i in home: | |
print i.text + " >> " + i.user.screen_name | |
else: | |
api.update_status(a) | |
while(1): | |
start() |
you want to see the frequency of how many times your handle is mentioned by a particular user?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
•if i want to (Show all the mentions in the user timeline with a count of how many times each one occurred. )
how can i do it ?