Python TweepError:错误的身份验证数据
因此,我目前正在进行一个创建twitter机器人的项目,尝试在cmd中运行以下命令时遇到问题:Python TweepError:错误的身份验证数据,python,web-scraping,beautifulsoup,tweepy,Python,Web Scraping,Beautifulsoup,Tweepy,因此,我目前正在进行一个创建twitter机器人的项目,尝试在cmd中运行以下命令时遇到问题: api.提到时间线() 当我在pythonshell中输入API时,它返回,这是预期的结果 我只创建了一个包含所有twitter api/tweepy密钥的文件: import tweepy ACCESS_TOKEN = "########" ACCESS_TOKEN_SECRET = "############" CONSUMER_KEY = "#################" CONSUMER
api.提到时间线()
当我在pythonshell中输入API时,它返回
,这是预期的结果
我只创建了一个包含所有twitter api/tweepy密钥的文件:
import tweepy
ACCESS_TOKEN = "########"
ACCESS_TOKEN_SECRET = "############"
CONSUMER_KEY = "#################"
CONSUMER_SECRET = "################"
# OAuth process, using the keys and tokens
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
# Creation of the actual interface, using authentication
api = tweepy.API(auth, wait_on_rate_limit=True, wait_on_rate_limit_notify=True)
# collect tweets on #MRT
for tweet in tweepy.Cursor(api.search,q="MRT",count=100,
lang="en",rpp=100).items():
print (tweet.created_at, tweet.text)
通过运行api.indesions\u timeline()
返回以下错误消息:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python37\lib\site-packages\tweepy\binder.py", line 250, in _call
return method.execute()
File "C:\Python37\lib\site-packages\tweepy\binder.py", line 234, in execute
raise TweepError(error_msg, resp, api_code=api_error_code)
tweepy.error.TweepError: [{'code': 215, 'message': 'Bad Authentication data.'}]
>>>
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
文件“C:\Python37\lib\site packages\tweepy\binder.py”,第250行,在\u调用中
返回方法execute()
文件“C:\Python37\lib\site packages\tweepy\binder.py”,第234行,在execute中
raise TweepError(错误消息,响应,api代码=api错误代码)
tweepy.error.TweepError:[{'code':215,'message':'Bad Authentication data.}]
>>>
预期结果应返回一些数据。Tweepy无法验证您的身份。请尝试用您独特的代码再次填写密钥和机密。这就是我如何解决此问题的方法。您如何尝试运行
api。提到了\u timeline()
?此代码段仅显示api.search
以下是cmd中的完整命令的外观>api>>api。在文件“C:\Python37\lib\site packages\tweepy\binder.py”的第250行中提到了\u timeline()回溯(最近一次调用):文件“”,第1行,在_callreturn method.execute()文件“C:\Python37\lib\site packages\tweepy\binder.py”的第234行中,在execute raise TweepError(error\u msg,resp,api\u code=api\u error\u code)tweepy.error.TweepError:[{'code':215,‘message':'错误的身份验证数据。}>>>
我仍然不知道您试图如何调用这个脚本。