1. <small id='yIW7D'></small><noframes id='yIW7D'>

    <legend id='yIW7D'><style id='yIW7D'><dir id='yIW7D'><q id='yIW7D'></q></dir></style></legend>

      <bdo id='yIW7D'></bdo><ul id='yIW7D'></ul>

    <tfoot id='yIW7D'></tfoot>
      <i id='yIW7D'><tr id='yIW7D'><dt id='yIW7D'><q id='yIW7D'><span id='yIW7D'><b id='yIW7D'><form id='yIW7D'><ins id='yIW7D'></ins><ul id='yIW7D'></ul><sub id='yIW7D'></sub></form><legend id='yIW7D'></legend><bdo id='yIW7D'><pre id='yIW7D'><center id='yIW7D'></center></pre></bdo></b><th id='yIW7D'></th></span></q></dt></tr></i><div id='yIW7D'><tfoot id='yIW7D'></tfoot><dl id='yIW7D'><fieldset id='yIW7D'></fieldset></dl></div>

      我怎么才能让这个机器人连续运行呢?

      How do I make this bot run continuously?(我怎么才能让这个机器人连续运行呢?)
    1. <small id='lI0CD'></small><noframes id='lI0CD'>

          <bdo id='lI0CD'></bdo><ul id='lI0CD'></ul>
          1. <tfoot id='lI0CD'></tfoot>

              <tbody id='lI0CD'></tbody>
                <i id='lI0CD'><tr id='lI0CD'><dt id='lI0CD'><q id='lI0CD'><span id='lI0CD'><b id='lI0CD'><form id='lI0CD'><ins id='lI0CD'></ins><ul id='lI0CD'></ul><sub id='lI0CD'></sub></form><legend id='lI0CD'></legend><bdo id='lI0CD'><pre id='lI0CD'><center id='lI0CD'></center></pre></bdo></b><th id='lI0CD'></th></span></q></dt></tr></i><div id='lI0CD'><tfoot id='lI0CD'></tfoot><dl id='lI0CD'><fieldset id='lI0CD'></fieldset></dl></div>
              • <legend id='lI0CD'><style id='lI0CD'><dir id='lI0CD'><q id='lI0CD'></q></dir></style></legend>
              • 本文介绍了我怎么才能让这个机器人连续运行呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                脚本在100个项目后停止,然后我必须重新运行 它是手动的。我如何才能自动执行此操作并拥有脚本 是否自动重新运行?

                #IMPORT LIBRARIES 
                import tweepy
                import time
                
                # API KEYS AND TOKENS
                api_key= "API KEY GOES IN HERE"
                api_key_secret = "API SECRET KEY GOES IN HERE"
                access_token = "ACCESS TOKEN GOES HERE"
                access_token_secret = "SECRET ACCESS TOKEN GOES HERE"
                
                # AUTHENTICATING TWITTER
                auth = tweepy.OAuthHandler(api_key, api_key_secret)
                auth.set_access_token(access_token , access_token_secret)
                api = tweepy.API(auth, wait_on_rate_limit=True)
                
                # HASHTAG AND NUMBER OF ITEMS
                hashtag = "#AmisomOut"
                tweet_number = 100
                
                # THE CURSOR METHOD
                tweets = tweepy.Cursor(api.search, hashtag).items(tweet_number)
                
                
                def searchBot():
                    for tweet in tweets:
                        try:
                            tweet.retweet()
                            print("retweet done!")
                            time.sleep(2)
                        except tweepy.TweepError as e:
                            print(e.reason)
                            time.sleep(15)
                
                searchBot()
                

                推荐答案

                将您要重复的代码放在while循环中将使其无限重复。在这种情况下,您似乎只需要重复某些代码即可获得所需的结果。

                首先,定义您的searchBot函数,然后将以下行放入循环中:

                while True:
                    tweets = tweepy.Cursor(api.search, hashtag).items(tweet_number)
                    searchBot()
                

                这将一直持续到您通过退出终端窗口或按ctrl+c手动退出程序为止。

                这篇关于我怎么才能让这个机器人连续运行呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)
                Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)
                Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)
                Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)
                Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)
                Grouping pandas DataFrame by 10 minute intervals(按10分钟间隔对 pandas 数据帧进行分组)
                  <tbody id='rXYNc'></tbody>
                <i id='rXYNc'><tr id='rXYNc'><dt id='rXYNc'><q id='rXYNc'><span id='rXYNc'><b id='rXYNc'><form id='rXYNc'><ins id='rXYNc'></ins><ul id='rXYNc'></ul><sub id='rXYNc'></sub></form><legend id='rXYNc'></legend><bdo id='rXYNc'><pre id='rXYNc'><center id='rXYNc'></center></pre></bdo></b><th id='rXYNc'></th></span></q></dt></tr></i><div id='rXYNc'><tfoot id='rXYNc'></tfoot><dl id='rXYNc'><fieldset id='rXYNc'></fieldset></dl></div>
                • <bdo id='rXYNc'></bdo><ul id='rXYNc'></ul>

                    • <tfoot id='rXYNc'></tfoot>

                          <legend id='rXYNc'><style id='rXYNc'><dir id='rXYNc'><q id='rXYNc'></q></dir></style></legend>

                          <small id='rXYNc'></small><noframes id='rXYNc'>