I think here can use the analogous for Python (urlparse.urlsplit, IIRC)