python - AttributeError:“NoneType”对象没有属性“create_favorite”
问题描述
我正在尝试使 twitter 自动化一点,但在 Tweepy 上的 auto like 功能上出现以下错误
Traceback (most recent call last):
File "/Users/dusandev/Desktop/TwitterBot/bot.py", line 15, in <module>
tweet.favorite()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-
packages/tweepy/models.py", line 375, in favorite
return self._api.create_favorite(self.id)
AttributeError: 'NoneType' object has no attribute 'create_favorite'
这是代码:
import tweepy
import time
auth = tweepy.OAuthHandler('xxxxxxxx','xxxxxx')
auth.set_access_token('xxxx-xxxx','xxxxxx')
api = tweepy.API(auth, wait_on_rate_limit=True)
search = 'solana'
number_of_tweets = 50
for tweet in tweepy.Cursor(api.search_tweets, search).items(number_of_tweets):
try:
print('Tweet Liked')
tweet.favorite()
time.sleep(10)
except tweepy.TweepyException as e:
print(e)
except StopIteration:
break
谢谢您的帮助!
解决方案
推荐阅读
- javascript - 如何在 WebStorm 的同一行上制作正确的大括号?
- arrays - 如何将数据推送到数组 ReactJs
- javascript - MongoDB 和 NodejS 中的搜索号
- excel - Excel 条件格式以识别特定的区分大小写的文本
- html - 如何在运行时使用 jQuery 更改按钮元素的 id
- regex - 正则表达式不匹配同一行上的所有实例
- python - 删除列表中两个项目之间(包括)的所有项目
- javascript - JS - 将此设置为主父级
- java - 发送消息后,客户端应如何正确等待服务器的响应?
- salesforce - 如何在 Mule 4 中使用 Salesforce 复合连接器“创建对象树”访问查找对象值