【发布时间】:2017-01-21 16:55:32
【问题描述】:
我的代码在 python 中如下所示,我一直收到此错误。
#Import the necessary methods from tweepy library
from tweepy.streaming import StreamListener
from tweepy import OAuthHandler
from tweepy import Stream
#Variables that contains the user credentials to access Twitter API
consumer_key = ''
consumer_secret = ''
access_token = ''
access_secret = ''
#This is a basic listener that just prints received tweets to stdout.
class StdOutListener(StreamListener):
def on_data(self, data):
print data
return True
def on_error(self, status):
print status
if __name__ == '__main__':
#This handles Twitter authetification and the connection to Twitter Streaming API
l = StdOutListener()
auth = OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_secret)
stream = Stream(auth, l)
#This line filter Twitter Streams to capture data by the keywords: 'python', 'javascript', 'ruby'
stream.filter(track=['python', 'javascript', 'ruby'])
我在此链接上关注本教程,了解如何从 twitter 挖掘数据并在此基础上进行一些分析。 错误是这样的
samuel@samuel-Satellite-C850-B908:~/twitter_demo$ python twitter_streaming.py
401
401
401
401
401
401
401
它会逐行打印 401。问题是什么?谁能帮帮我?
【问题讨论】:
-
查找 HTTP 错误 401