code: def parse_url(url):
      
      try:
          url = unicode(url)
      except UnicodeDecodeError:
          pass
  
      if py3k:
          make_utf8 = lambda x: x
      else:
          make_utf8 = lambda x: isinstance(x, unicode) and x.encode('utf-8') or x
  
      if '://' in url:
          scheme, url = url.split('://', 1)
      else:
          scheme = 'http'
      url = 'http://' + url
      parsed = urlparse.urlsplit(url)
      r = ObjectDict()
      r['scheme'] = make_utf8(scheme)
      r['netloc'] = make_utf8(parsed.netloc)
      r['path'] = make_utf8(parsed.path)
      r['query'] = make_utf8(parsed.query)
      r['fragment'] = make_utf8(parsed.fragment)
      r['uri'] = make_utf8(parsed.path)
      if parsed.query:
          r['uri'] += '?' + make_utf8(parsed.query)
      r['username'] = make_utf8(parsed.username)
      r['password'] = make_utf8(parsed.password)
      host = make_utf8(parsed.hostname.encode('idna').decode('utf-8'))
      r['host'] = r['hostname'] = host
      try:
          r['port'] = parsed.port
      except ValueError:
          r['port'] = None
      if r['port']:
          r['http_host'] = '%s:%d' % (r['host'], r['port'])
      else:
          r['http_host'] = r['host']
  
      return r
docs: Return a dictionary of parsed url
  
      Including scheme, netloc, path, params, query, fragment, uri, username,
      password, host, port and http_host