分享

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

LINGLUOXIANSEN 发表于 2016-2-18 20:45:44 [显示全部楼层] 回帖奖励 阅读模式 关闭右栏 2 12886
这里为了在twitter api获取数据,运用stream api获取数据进行测试,在根据官方教程出现问题,采纳的教程链接 https://www.youtube.com/watch?v=pUUxmvvl2FE
   代码:
from tweepy import Streamfrom tweepy import OAuthHandler
from tweepy.streaming import StreamListener

atoken = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
asecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
ckey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
csecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"


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 具体问题原因是什么请帮忙指出

已有(2)人评论

跳转到指定楼层
atsky123 发表于 2016-2-19 10:20:25
被墙了,看不到网站。
不过从程序来看是链接出问题了
回复

使用道具 举报

LINGLUOXIANSEN 发表于 2016-2-19 11:15:22
atsky123 发表于 2016-2-19 10:20
被墙了,看不到网站。
不过从程序来看是链接出问题了

你倒腾过 使用twitter api么??
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条