def guess_url ( url ) : if url . lower ( ) . startswith ( "www." ) : # syntactic sugar return "http://%s" % url elif url . lower ( ) . startswith ( "ftp." ) : # syntactic sugar return "ftp://%s" % url return url
python unknown url type https
Guess if URL is a http or ftp URL .
def guess_url(url):
    """Guess if URL is a http or ftp URL.
    @param url: the URL to check
    @ptype url: unicode
    @return: url with http:// or ftp:// prepended if it's detected as
      a http respective ftp URL.
    @rtype: unicode
    """
    if url.lower().startswith("www."):
        # syntactic sugar
        return "http://%s" % url
    elif url.lower().startswith("ftp."):
        # syntactic sugar
        return "ftp://%s" % url
    return url