helpers.py 文件源码

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

项目:Silver-Screen 作者: bfbachmann 项目源码 文件源码
def __init__(self):
        ## Load the API keys
        try:
            stream = open("app/models/api_keys.yml", 'r')
            keys = yaml.load(stream)
        except:
            print('Failed to load Twitter API keys from file, falling back on environment variables')
            keys = {
                'consumer_key': os.environ['consumer_key'],
                'consumer_secret': os.environ['consumer_secret'],
                'access_token_key': os.environ['access_token_key'],
                'access_token_secret': os.environ['access_token_secret'],
            }

        self.api = twitter.Api(consumer_key=keys['consumer_key'], consumer_secret=keys['consumer_secret'], access_token_key=keys['access_token_key'],  access_token_secret=keys['access_token_secret'], sleep_on_rate_limit=False) # NOTE: setting sleep_on_rate_limit to True here means the application will sleep when we hit the API rate limit. It will sleep until we can safely make another API call. Making this False will make the API throw a hard error when the rate limit is hit.

    ## Request tweets for a given movie
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号