如何解决为什么我的 tweepy bot 喜欢我自己的推文而不是指定的用户 ID?
所以我一直在尝试在 tweepy 中创建自动喜欢和关注的功能,它们都有效。但是,我想做的一个功能是收藏特定用户的完整推文时间线。我一直在运行的代码是这样的:
import tweepy
import logging
from config import create_api
import time
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger()
def main():
api = create_api()
for status in api.user_timeline(user_id='a user name here',count= 100,include_rts= True):
if not status.favorited:
try:
status.favorite()
logger.info(f"Favorited id {status.id}")
time.sleep(20)
except Exception as e:
logger.error("There was a fav error",exec_info=True)
if __name__ == "__main__":
main()
所以收藏是有效的,但它收藏的是我自己的所有推文,而不是指定的 user_id 或 screen_name 。我不太确定为什么。我尝试过“for tweet”和不同的方式来说明 api.user_timeline,但它只是一直喜欢我自己的推文。
API 来自我的配置文件,我使用 os.getenv 从我的 shell 命令中获取 access_token 和我的 twitter bot 配置文件以增加安全性。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。