code: def query_tweets_once_generator(query, limit=None, lang='', pos=None):
      
      logger.info('Querying {}'.format(query))
      query = query.replace(' ', '%20').replace('#', '%23').replace(':', '%3A')
      num_tweets = 0
      try:
          while True:
              new_tweets, new_pos = query_single_page(query, lang, pos)
              if len(new_tweets) == 0:
                  logger.info('Got {} tweets for {}.'.format(
                      num_tweets, query))
                  return
  
              for t in new_tweets:
                  yield t, pos
  
              # use new_pos only once you have iterated through all old tweets
              pos = new_pos
  
              num_tweets += len(new_tweets)
  
              if limit and num_tweets >= limit:
                  logger.info('Got {} tweets for {}.'.format(
                      num_tweets, query))
                  return
  
      except KeyboardInterrupt:
          logger.info('Program interrupted by user. Returning tweets gathered '
                       'so far...')
      except BaseException:
          logger.exception('An unknown error occurred! Returning tweets '
                            'gathered so far.')
      logger.info('Got {} tweets for {}.'.format(
          num_tweets, query))
docs: Queries twitter for all the tweets you want! It will load all pages it gets
      from twitter. However, twitter might out of a sudden stop serving new pages,
      in that case, use the `query_tweets` method.
  
      Note that this function catches the KeyboardInterrupt so it can return
      tweets on incomplete queries if the user decides to abort.
  
      :param query: Any advanced query you want to do! Compile it at
                    https://twitter.com/search-advanced and just copy the query!
      :param limit: Scraping will be stopped when at least ``limit`` number of
                    items are fetched.
      :param pos: Field used as a "checkpoint" to continue where you left off in iteration
      :return:      A list of twitterscraper.Tweet objects. You will get at least
                    ``limit`` number of items.