_extractors.py 文件源码

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

项目:probablyPOTUS 作者: jjardel 项目源码 文件源码
def _initialize_api(self):
        """
        Handles authentication with Twitter API using tweepy.
        Requires a file at config/twitter_creds.json with the following attributes:

            "access_token":
            "access_secret":
            "consumer_token":
            "consumer_secret":

        See Twitter OAUTH docs + Tweepy docs for more details http://docs.tweepy.org/en/v3.5.0/auth_tutorial.html
        :return:
        """

        with open(self.loc.format('../config/twitter_creds.json')) as fp:
            config = json.load(fp)

        auth = tweepy.OAuthHandler(config['consumer_token'], config['consumer_secret'])
        auth.set_access_token(config['access_token'], config['access_secret'])
        self.logger.info('Successfully Authenticated to Twitter API')

        self.api = tweepy.API(auth)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号