Last active
August 29, 2015 14:25
-
-
Save utgwkk/09cccc398a0ac20f5ee7 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
# -*- coding: utf-8 -*- | |
# NOTE: use Python 3. | |
import tweepy | |
import re | |
import sys | |
CONSUMER_KEY = '' | |
CONSUMER_SECRET = '' | |
me = 'YOUR_SCREEN_NAME' | |
class Listener(tweepy.StreamListener): | |
def on_status(self,s): | |
try: | |
if 'レイバン' in s.text and '@' in s.text and not 'RT' in s.text: | |
api.update_status('@%s レイバンを検出しました'%(s.author.screen_name), s.id) | |
except Exception,e: | |
pass | |
finally: | |
return True | |
if __name__ == '__main__': | |
auth = tweepy.OAuthHandler(CONSUMER_KEY,CONSUMER_SECRET) | |
print(auth.get_authorization_url()) | |
verifier = raw_input('PIN: ').rstrip() | |
try: | |
auth.get_access_token(verifier) | |
auth.set_access_token(auth.access_token.key, auth.access_token.secret) | |
api = tweepy.API(auth) | |
me = api.me().screen_name | |
except tweepy.TweepError: | |
pass | |
else: | |
stream = tweepy.Stream(auth, Listener()) | |
stream.userstream() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment