我认为我的大学最近改变了关于Twitter的流媒体API的防火墙或过滤协议。但是,为了向我们提供更多信息,我将不得不弄清楚细节。
好的,下面是从Twitter的流中收集数据的最简单的程序:
from tweepy import Stream
from tweepy import OAuthHandler
from tweepy.streaming import StreamListener
ckey="[OMITED]"
csecret="[OMITED]"
atoken="[OMITED]"
asecret="[OMITED]"
class listener(StreamListener):
def on_data(self, data):
print(data)
return(True)
def on_error(self, status):
print status
auth = OAuthHandler(ckey, csecret)
auth.set_access_token(atoken, asecret)
twitterStream = Stream(auth, listener())
twitterStream.filter(track=["car"])
当我在笔记本电脑/家用台式机上运行此程序时,它运行正常。但是,我有一个用于数据收集的大学计算机设置,它会产生以下错误:
Traceback (most recent call last):
File "test.py", line 25, in <module>
twitterStream.filter(track=["car"])
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tweepy/streaming.py", line 228, in filter
self._start(async)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tweepy/streaming.py", line 172, in _start
self._run()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tweepy/streaming.py", line 106, in _run
conn.connect()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1278, in connect
server_hostname=server_hostname)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 352, in wrap_socket
_context=self)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 579, in __init__
self.do_handshake()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 808, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)
现在,问题是,我可以打开Safari并浏览网页。此外,像这样的数据收集工作(截至一个月前)。该错误表明SSL证书验证失败(但奇怪的是原始OAuth似乎有效 - 这是启动错误的过滤器命令)。有没有办法让它吐出来,如果那是因为中间证书已经到位?或者一个端口被阻止?基本上,有没有办法获得更多细节,所以我可以去大学并说:“你正在阻止X&#39;?
有什么建议吗?
答案 0 :(得分:0)
我已经解决了这个问题。与使用Digicerts签署的SSL站点相关的错误。