def add_http_if_no_scheme(url):
 match = re.match('^\\w+://', url, flags=re.I)
 if (not match):
  parts = urlparse(url)
  scheme = ('http:' if parts.netloc else 'http://')
  url = (scheme + url)
 return url

def add_http_if_no_scheme ( url ) : match = re . match ( '^\\w+://' , url , flags = re . I ) if ( not match ) : parts = urlparse ( url ) scheme = ( 'http:' if parts . netloc else 'http://' ) url = ( scheme + url ) return url
add http as the default scheme if it is missing from the url .