跟着官方教程运行stream api exmaple 报错

暗淡星空 2016-02-18 08:22:42
这里为了在twitter api获取数据,运用stream api获取数据进行测试,在根据官方教程出现问题,采纳的教程链接 https://www.youtube.com/watch?v=pUUxmvvl2FE
代码:
from tweepy import Stream
from tweepy import OAuthHandler
from tweepy.streaming import StreamListener

atoken = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
asecret = "Jxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
ckey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
csecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"


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"])

这里密钥相关采用的是我申请的,但是在运行的时候出现如下的调试问题
raceback (most recent call last):
File "D:/project/python_project/TestStream/StreamApi.py", line 23, in <module>
twitterStream.filter(track=["car"])
File "build\bdist.win-amd64\egg\tweepy\streaming.py", line 445, in filter
File "build\bdist.win-amd64\egg\tweepy\streaming.py", line 361, in _start
File "build\bdist.win-amd64\egg\tweepy\streaming.py", line 294, in _run
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='stream.twitter.com', port=443): Max retries exceeded with url: /1.1/statuses/filter.json?delimited=length (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x0000000002F7D5F8>: Failed to establish a new connection: [Errno 10060] ',))
另外:我使用的是python 2.7 具体问题原因是什么请帮忙指出

...全文
3374 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
海兰 2016-03-30
  • 打赏
  • 举报
回复
你用的版本跟教程里边的是不是一样的呀?

2,245

社区成员

发帖
与我相关
我的任务
社区描述
OpenAPI
社区管理员
  • OpenAPI社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧