code: def run_active_scan(self, target_url, recursive=False, context_name=None, user_name=None):
          
          self.logger.debug('Scanning 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('Scanning in context {0} as user {1}'.format(context_id, user_id))
              scan_id = self.zap.ascan.scan_as_user(target_url, context_id, user_id, recursive)
          else:
              scan_id = self.zap.ascan.scan(target_url, recurse=recursive)
  
          if not scan_id:
              raise ZAPError('Error running active scan.')
          elif not scan_id.isdigit():
              raise ZAPError(('Error running active scan: "{0}". Make sure the URL is in the site ' +
                              'tree by using the open-url or scanner commands before running an active ' +
                              'scan.').format(scan_id))
  
          self.logger.debug('Started scan with ID {0}...'.format(scan_id))
  
          while int(self.zap.ascan.status()) < 100:
              self.logger.debug('Scan progress %: {0}'.format(self.zap.ascan.status()))
              time.sleep(self._status_check_sleep)
  
          self.logger.debug('Scan #{0} completed'.format(scan_id))
docs: Run an active scan against a URL.