[英]How to make a Twitter bot run remotely and automatically
我刚刚在 Python 中构建了一个具有提升访问权限的 Twitter 机器人。 该机器人转发包含特定主题标签的推文。 它工作得很好,但我必须点击“运行”才能找到并转发所说的推文。
我怎样才能让这个运行机器人自动运行? 请注意,我没有太多的编码经验,我是从基础开始的,我在一些在线教程的帮助下构建了这个机器人。
这是代码:
for tweet in tweepy.Cursor(api.search_tweets, q='#myhashtag OR #myhashtag2').items(15):
try:
print('\nHi! I found this tweet by @' + tweet.user.screen_name + '. ')
tweet.retweet()
print('Retweeted.')
# Where sleep(10), sleep is measured in seconds.
# Change 10 to amount of seconds you want to have in-between retweets.
# Read Twitter's rules on automation. Don't spam!
sleep(5)
# Some basic error handling. Will print out why retweet failed, into your terminal.
except tweepy.errors.TweepError as error:
print('\nError. Couldn't retweet. Reason: ')
print(error.reason)
except StopIteration:
break
谢谢!
您的意思是像在线 24/7 一样自动?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.