Hi I'm new to Python so forgive me if this seems a little obvious but I can't see that it's been asked before.
I'm writing something to 'clean' a URL. In this case all I'm trying to do is return a faked scheme as urlopen won't work without one. However, if I test this with 'www.python.org' It'll return http:///www.python.org. Does anyone know why the extra /, and is there a way to return this without it?
Thank you very much.
def FixScheme(website):
from urlparse import urlparse, urlunparse
scheme, netloc, path, params, query, fragment = urlparse(website)
if scheme == '':
return urlunparse(('http', netloc, path, params, query, fragment))
else:
return website