Created
January 4, 2012 13:27
-
-
Save morris555/1560029 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
#!/usr/bin/env python | |
# -*- coding:utf-8 -*- | |
import tweepy | |
import sys | |
def get_oauth(): | |
consumer_key = '' | |
consumer_secret = '' | |
access_key = '' | |
access_secret = '' | |
auth = tweepy.OAuthHandler(consumer_key, consumer_secret) | |
auth.set_access_token(access_key, access_secret) | |
return auth | |
class StreamListener(tweepy.StreamListener): | |
def on_status(self, status): | |
tweet = status | |
id = tweet.id | |
if tweet.favorited == True: | |
pass | |
fav = tweepy.API(auth_handler=get_oauth()).create_favorite(id) | |
print("({text})をふぁぼりました。".format(text=tweet.text)) | |
def get_user_id(screen_name, api): | |
user_id = api.get_user(screen_name).id | |
return user_id | |
def main(): | |
auth = get_oauth() | |
api = tweepy.API(auth_handler=auth) | |
screen_name = sys.argv[1] | |
stream = tweepy.Stream(auth, StreamListener()) | |
try: | |
stream.filter(follow=[get_user_id(screen_name, api)]) | |
except KeyboardInterrupt: | |
sys.exit() | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment