I am writing something to 'clean' a URL. Whatever I am trying to do in this case, it returns a fake scheme because urlopen
will not work without any, however, if I call it www.python.org
, it will return to http: ///www.python.org
. Does anyone know that additional /, and what is there any way to return it without it? DEF fix (website): urlparse import urlparse, urlunparse scheme, netlok, path, parameter, query, merge = urlparse (website) if plan == '': return urlunparse ((' Http ', netloc, path, params, query, piece)) Other: return website
The problem is that the strings in parsing too incomplete URL www.python.org
that you give is actually the path
component of the URL Is taken as, in which netloc
(network Than) is a clear and well planned. You can actually pass the second parameter scheme
to urlparse
(make your logic easy) to miss this plan, but with the "empty netlock" problem If you do not help, then you need some logic for the that case, for example
if not netloc: netloc, path = path, ''
Comments
Post a Comment