Created
May 12, 2010 14:20
-
-
Save k-saka/398639 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 -*- | |
import sys | |
import tweepy | |
from pit import Pit | |
def get_api(): | |
token = Pit.get('tw_oauth') | |
auth = tweepy.OAuthHandler(consumer_key = token['consumer_key'], consumer_secret = token['consumer_secret']) | |
auth.set_access_token(key = token['access_token'], secret = token['access_token_secret']) | |
api = tweepy.API(auth) | |
return api | |
def get_list_member(api): | |
users = [] | |
for mem in tweepy.Cursor(api.list_members,'healthyboy4','waseda-jinka').items(): | |
users.append(int(mem.id)) | |
for mem in tweepy.Cursor(api.list_members,'atsushikinjo','ie').items(): | |
users.append(int(mem.id)) | |
return users | |
class StreamListener(tweepy.StreamListener): | |
def on_status(self, status): | |
print '【'+status.user.screen_name+'】',status.text | |
def on_delete(self,status_id,user_id): | |
print status_id | |
def stream(users): | |
conf = Pit.get('twitter') | |
user = conf['id'] | |
passwd = conf['password'] | |
stream = tweepy.Stream(user, passwd, StreamListener()) | |
stream.filter(follow=users) | |
def main(): | |
users = get_list_member(get_api()) | |
stream(users) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment