我的代码在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。问题是什么?任何人都可以帮助我吗?
答案 0 :(得分:0)
检查您的系统时间,如果需要,请使用全球时间服务器更新/同步它。如果您的系统在几分钟后关闭,Twitter经常会抛出401 Unauthorized。
编辑:PS - 我假设你有有效的访问权限!