code: def parse(url_str):
      
      url_str = to_unicode(url_str)
      result = urlparse(url_str)
      netloc_parts = result.netloc.rsplit('@', 1)
      if len(netloc_parts) == 1:
          username = password = None
          host = netloc_parts[0]
      else:
          user_and_pass = netloc_parts[0].split(':')
          if len(user_and_pass) == 2:
              username, password = user_and_pass
          elif len(user_and_pass) == 1:
              username = user_and_pass[0]
              password = None
          host = netloc_parts[1]
  
      if host and ':' in host:
          host = host.split(':')[0]
  
      return {'host': host,
              'username': username,
              'password': password,
              'scheme': result.scheme,
              'port': result.port,
              'path': result.path,
              'query': result.query,
              'fragment': result.fragment}
docs: Extract all parts from a URL string and return them as a dictionary