input: Write a function to implement a Python API for KB SRU, which allows users to create an instance of the "sru" class and call its "search" method to perform searches based on a query string and optionally a collection name, start record number, maximum number of records to return, and record schema. The method should return a "response" object containing the search results, from which specific information such as titles, creators, and subjects can be extracted.
  
  
  from lxml import etree
  import requests
  import urllib
  import sys
  
  SRU_BASEURL = 'http://jsru.kb.nl/sru/sru?version=1.2&maximumRecords=%i&operation=searchRetrieve&startRecord=%i&recordSchema=%s&x-collection=%s&query=%s'
  
  SETS = {
      'ANP': {'collection': 'ANP', 'recordschema': 'dcx', 'setname': 'anp'},
      'DPO': {'collection': 'DPO_boekdeel', 'recordschema': 'ddd', 'setname': 'DPO'},
      'BYVANCK': {'collection': '', 'recordschema': 'dcx', 'setname': 'BYVANCK'},
      'SGD': {'collection': '', 'recordschema': 'dcx', 'setname': 'sgd:register'},
      'GGC': {'collection': 'GGC', 'recordschema': 'dcx', 'setname': 'ggc'}
  }
  
  class response:
      def __init__(self, record_data, sru):
          self.record_data = record_data
          self.sru = sru
  
      def getElementText(self, tagName, attributeName, attributeValue):
          textFields = []
          for r in self.record_data.iter():
              if r.tag == tagName:
                  if attributeName != '' and r.attrib.get(attributeName) == attributeValue:
                      textFields.append(r.text)
                  elif attributeName == '':
                      textFields.append(r.text)
          return textFields
  
      @property
      def titles(self):
          return self.getElementText('{http://purl.org/dc/elements/1.1/}title', '', '')
  
      @property
      def creators(self):
          return self.getElementText('{http://purl.org/dc/elements/1.1/}creator', '', '')
  
      @property
      def subjects(self):
          return self.getElementText('{http://purl.org/dc/elements/1.1/}subject', '', '')
  
  class sru:
      def __init__(self):
          self.sru_collections = SETS
  
      def search(self, query, collection=False, startrecord=1, maximumrecords=1, recordschema=False):
          if collection not in self.sru_collections:
              raise Exception('Unknown collection')
          
          collection_info = self.sru_collections[collection]
          collection_name = collection_info['collection'] or collection
          record_schema = recordschema or collection_info['recordschema']
  
          if sys.version.startswith('3'):
              quoted_query = urllib.parse.quote_plus(query)
          elif sys.version.startswith('2'):
              quoted_query = urllib.quote_plus(query)
  
          url = SRU_BASEURL % (maximumrecords, startrecord, record_schema, collection_name, quoted_query)
          r = requests.get(url)
  
          if r.status_code != 200:
              raise Exception('Error while getting data from %s' % url)
  
          record_data = etree.fromstring(r.content)
          nr_of_records = int(next(i.text for i in record_data.iter() if i.tag.endswith('numberOfRecords')))
  
          if nr_of_records > 0:
              return response(record_data, self)
          return False
  
  # Test cases
  assert isinstance(sru().search('test', 'GGC'), response) == True
  assert isinstance(sru().search('test', 'GGC'), response) == False
  assert isinstance(sru().search('Python', 'DPO').titles, list) == True
  assert isinstance(sru().search('Python', 'DPO').creators, list) == True
  assert isinstance(sru().search('Python', 'DPO').subjects, list) == True
  
output: def search(self, query, collection=False, startrecord=1, maximumrecords=1, recordschema=False):
      if collection not in self.sru_collections:
          raise Exception('Unknown collection')
      
      collection_info = self.sru_collections[collection]
      collection_name = collection_info['collection'] or collection
      record_schema = recordschema or collection_info['recordschema']
  
      if sys.version.startswith('3'):
          quoted_query = urllib.parse.quote_plus(query)
      elif sys.version.startswith('2'):
          quoted_query = urllib.quote_plus(query)
  
      url = SRU_BASEURL % (maximumrecords, startrecord, record_schema, collection_name, quoted_query)
      r = requests.get(url)
  
      if r.status_code != 200:
          raise Exception('Error while getting data from %s' % url)
  
      record_data = etree.fromstring(r.content)
      nr_of_records = int(next(i.text for i in record_data.iter() if i.tag.endswith('numberOfRecords')))
  
      if nr_of_records > 0:
          return response(record_data, self)
      return False