pubsub_twitter.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:oscars2016 作者: 0x0ece 项目源码 文件源码
def twitter_stream(client, project_name, topic, track_list):
    """Connects to Twitter stream API."""
    print 'Connecting to Twitter...'

    with open('twitter.json') as f:
        twitter_cred = json.load(f)
    auth = tweepy.auth.OAuthHandler(twitter_cred['consumer_key'], twitter_cred['consumer_secret'])
    auth.set_access_token(twitter_cred['access_token'], twitter_cred['access_token_secret'])
    watcher = StreamWatcherListener(client=client, project=project_name, topic=topic)
    stream = tweepy.Stream(auth, watcher, timeout=None)

    track_list = [k for k in track_list.split(',')]
    stream.filter(None, track_list)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号