python - tweepy 库 连接Twitter API 报错
本文介绍了python - tweepy 库 连接Twitter API 报错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
环境:python 2.7.10 tweepy:3.5.0
错误:tweepy.error.TweepError: Failed to send request: [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:590)
代码:网上一个demo
import re
import tweepy
auth = tweepy.OAuthHandler("xxxxx",
"xxxxx")
auth.set_access_token("xxxxx",
"xxxxx")
api = tweepy.API(auth,proxy="127.0.0.1:1080")
highpoints = re.compile(u'uD800-uDBFF')
public_tweets = api.home_timeline()
num = 0
for tweet in public_tweets:
print num
num += 1
text_noem = highpoints.sub('--emoji--', tweet.text)
text_noem = text_noem.encode('utf8')
求大神指点,什么原因呢?
解决方案
原来是代理服务器不支持http协议,换了代理就可以了
这篇关于python - tweepy 库 连接Twitter API 报错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文