parse url for domain and homepage

    :param url: the req url
    :type url: str
    :return: (homepage, domain)
    :rtype:
509112
def get_domain_home_from_url(url):
    
    p = parse.urlparse(url)
    if p.netloc:
        return '{}://{}'.format(p.scheme, p.netloc), p.netloc
    else:
        return '', ''
816177
def _url(self, url):
        

        protocol = 'https' if self.https else 'http'
        return '{0}://{1}/spaces/{2}{3}'.format(
            protocol,
            self.api_url,
            self.space_id,
            url
        )
1634
def match(self, url: str) -> RouteResolved:
        
        url = normalize_url(url)
        parts = self._deconstruct_url(url)
        return self._match(parts)
998507
def getResponse(self, url):
             
        # Defining an empty object for the response
        response = {}
        try:
            # This receives only the parameters needed by this Tor Wrapper:
            # {
            #    "host" : "127.0.0.1"
            #    "port" : "9150"
            # }  
            self.info = self._getConfiguration()
        
            response = self._grabContentFromUrl(url)
        except Exception, e:
            response["status"] = { "code" : 400, "desc" : str(e) }            
            
        # Adding other known data            
        response["time_processed"] = str(dt.datetime.now())
        
        response["domain"] = self.getDomainFromUrl(url)
        response["url"] = url          

        try:
            # We'll check if something happened...    
            response["status"]
        except Exception, e:
            # If nothing happened till now, we'll set the code as 200             
            response["status"] = { "code" : 200, "desc" : "OK." }
                    
        return response
182444
def make_url(domain, location):
    

    url = urlparse(location)

    if url.scheme == '' and url.netloc == '':
        return domain + url.path
    elif url.scheme == '':
        return 'http://' + url.netloc + url.path
    else:
        return url.geturl()
469499
def url_host(url: str) -> str:
    
    from urllib.parse import urlparse
    res = urlparse(url)
    return res.netloc.split(':')[0] if res.netloc else ''
591941
def security(self, domain):
        '''
        '''
        uri = self._uris["security"].format(domain)
        return self.get_parse(uri)
894625
def url(self):
		
		return urlparse.urlunparse((self.scheme, self.host, self.path, None, None, None))
1153110
def parse_url(request, url):
    """"""
    try:
        validate = URLValidator()
        validate(url)
    except ValidationError:
        if url.startswith('/'):
            host = request.get_host()
            scheme = 'https' if request.is_secure() else 'http'
            url = '{scheme}://{host}{uri}'.format(scheme=scheme,
                                                  host=host,
                                                  uri=url)
        else:
            url = request.build_absolute_uri(reverse(url))
    return url
59690
def get_url(url, parser='html'):
    
    url = request.quote(url, safe=':/?=&')
    logger.debug('URL: %s', url)
    req = request.Request(url, headers={'User-Agent': 'foobar'})
    try:
        response = request.urlopen(req)
    except HTTPError:
        raise
    except (ssl.SSLError, URLError):
        # Some websites (like metal-archives) use older TLS versions and can
        # make the ssl module trow a VERSION_TOO_LOW error. Here we try to use
        # the older TLSv1 to see if we can fix that
        context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
        response = request.urlopen(req, context=context)

    response = response.read()
    if parser == 'html':
        return BeautifulSoup(response, 'html.parser', from_encoding='utf-8')
    elif parser == 'json':
        return json.loads(response)
    elif parser == 'raw':
        return response.decode()
    raise ValueError('Unrecognized parser')
300298
def url_to_string(url):
    
    try:
        page = urllib2.urlopen(url)
    except (urllib2.HTTPError, urllib2.URLError) as err:
        ui.error(c.MESSAGES["url_unreachable"], err)
        sys.exit(1)

    return page
1353072
def get_host(url):
    
    p = parse_url(url)
    return p.scheme or 'http', p.hostname, p.port
834384
def _load_url(url):
    
    try:
        response = requests.get(url)
        return BytesIO(response.content)
    except IOError as ex:
        parser.error("{url} could not be loaded remotely! ({ex})".format(url=url, ex=ex))
347943
def get_url(url: str) -> Union[dict, int, float, str]:
        ''''''

        request = Request(url, headers={"User-Agent": "pypeerassets"})
        response = cast(HTTPResponse, urlopen(request))
        if response.status != 200:
            raise Exception(response.reason)
        return json.loads(response.read().decode())
293294
def url(self, url):
        
        if url and url.endswith('/'):
            url = url[:-1]

        self._url = url
1064489
def data_url(contents, domain=DEFAULT_DOMAIN):
    
    url = (domain + '#data=data:application/json,' +
           urllib.parse.quote(contents))
    return url
1179396
def parse(url):
    
    parts = split(url)
    if parts.scheme:
        username, password, host, port = split_netloc(parts.netloc)
        subdomain, domain, tld = split_host(host)
    else:
        username = password = subdomain = domain = tld = port = ''
    return URL(parts.scheme, username, password, subdomain, domain, tld,
               port, parts.path, parts.query, parts.fragment, url)