SSLError:HTTPSConnectionPool(host ='stream.twitter.com',port = 443):

时间:2019-01-18 00:24:44

标签: python ssl tweepy

请告知缺少什么来解决以下SSL错误,我正在尝试在jupyter笔记本中流式传输Twitter feed

HTTPSConnectionPool(host ='stream.twitter.com',port = 443): 使用Tweepy的OAuthHandler

SSLError:HTTPSConnectionPool(host ='stream.twitter.com',port = 443):URL超过最大重试次数:/1.1/statuses/sample.json?delimited = length(由SSLError(SSLError(1,' [SSL:CERTIFICATE_VERIFY_FAILED]证书验证失败(_ssl.c:847)'),))

尝试所有选项 1. pip install-升级认证 pip安装PyOpenSSL 2.从tweepy导入OAuthHandler,Stream 进口ssl 汇入要求 进口插座 导入tweepy

从tweepy导入OAuthHandler,Stream的代码

导入ssl 汇入要求 进口插座 导入tweepy

from tweepy.streaming import StreamListener
     consumer_key = 'KKKK'
     consumer_secret = 'HHHHHH'
     access_token = 'WWWWWWW'
     access_token_secret = 'CCCCCCC'

auth = OAuthHandler(consumer_key,consumer_secret)
auth.set_access_token(access_token,access_token_secret)

class printListener(StreamListener):
    def on_status(self, status):
        print(status.text)
        print(status.author.screen_name,
            status.created_at,
            status.source,
            '\n')

def print_to_terminal():
    listener = printListener()
    stream = Stream(auth,listener)
    stream.sample()

if __name__ == '__main__':
    print_to_terminal()

0 个答案:

没有答案