有没有办法用python在twitter上留言?那么,有没有可以做到这一点的库呢?比如你把文章中的链接放在哪里,以及要发送的评论。提前感谢!
发布于 2021-10-13 16:58:24
您可以使用tweepy库,并使用update_status函数回复推文。
使用@提到一个用户,并使用tweet id。
reply = api.update_status("Hello world to @username", tweet.id)发布于 2021-10-13 16:57:12
你可以创建一个可以在帖子上发表评论的Twitter机器人,有很多机器人可以发布来自新闻网站的评论或Twitter上的新闻片段。我不认为有一个一体化的库可以做到这一点,但你可以使用这些库在python中构建自己的机器人。
beautifulsoup4==4.4.1
bs4==0.0.1
lxml==3.6.0
nltk==3.2.1
oauthlib==1.0.3
Pillow==3.2.0
requests==2.9.1
requests-oauthlib==0.6.1
simplejson==3.8.2
six==1.10.0
tweepy==3.5.0
Twython下面的程序将帮助您自动发布所有回复。它有一个延迟,这样Twitter就不会标记你的帐户为垃圾邮件。你需要身份验证和Twitter id,而不是你的,才能告诉机器人它应该在哪里发表评论。
id = str(id)
if id in ids_replied_to:
print('')
print('Skipped as already replied to')
print('')
print('')
else:
twitter_handle = '@' + screen_name
message = twitter_handle + " " + random.choice(rand_message)
twitter.update_status(status=message, in_reply_to_status_id=id)
print("Tweeted: %s" % message)
id = int(id)
ids_replied_to.append(id)
with open('ids_replied_to.txt', 'w') as filehandle:
filehandle.writelines("%s\n" % place for place in ids_replied_to)
# delay so that it doesn't look like the program is spamming Twitter
time.sleep(5)https://stackoverflow.com/questions/69559297
复制相似问题