小编use*_*380的帖子

401使用Tweepy检索Twitter数据时出错

我试图使用Tweepy检索Twitter数据,使用下面的代码,但我返回401错误,我重新生成访问和秘密令牌,并出现相同的错误.

#imports
from tweepy import Stream
from tweepy import OAuthHandler
from tweepy.streaming import StreamListener

#setting up the keys
consumer_key = 'xxxxxxx'
consumer_secret = 'xxxxxxxx' 
access_token = 'xxxxxxxxxx'
access_secret = 'xxxxxxxxxxxxx'

class TweetListener(StreamListener):
# A listener handles tweets are the received from the stream.
#This is a basic listener that just prints received tweets to standard output

   def on_data(self, data):
       print (data)
       return True

   def on_error(self, status):
       print (status)



#printing all the tweets to the standard output
auth = OAuthHandler(consumer_key, consumer_secret) …
Run Code Online (Sandbox Code Playgroud)

python twitter tweepy

13
推荐指数
2
解决办法
1万
查看次数

标签 统计

python ×1

tweepy ×1

twitter ×1