code: def run_spider(self, target_url, context_name=None, user_name=None):
          
          self.logger.debug('Spidering target {0}...'.format(target_url))
  
          context_id, user_id = self._get_context_and_user_ids(context_name, user_name)
  
          if user_id:
              self.logger.debug('Running spider in context {0} as user {1}'.format(context_id, user_id))
              scan_id = self.zap.spider.scan_as_user(context_id, user_id, target_url)
          else:
              scan_id = self.zap.spider.scan(target_url)
  
          if not scan_id:
              raise ZAPError('Error running spider.')
          elif not scan_id.isdigit():
              raise ZAPError('Error running spider: "{0}"'.format(scan_id))
  
          self.logger.debug('Started spider with ID {0}...'.format(scan_id))
  
          while int(self.zap.spider.status()) < 100:
              self.logger.debug('Spider progress %: {0}'.format(self.zap.spider.status()))
              time.sleep(self._status_check_sleep)
  
          self.logger.debug('Spider #{0} completed'.format(scan_id))
docs: Run spider against a URL.