49
¿Hay una biblioteca en python que funcione así?Resolución de una ruta de URL relativa a su ruta absoluta
>>> resolvePath("http://www.asite.com/folder/currentpage.html", "anotherpage.html")
'http://www.asite.com/folder/anotherpage.html'
>>> resolvePath("http://www.asite.com/folder/currentpage.html", "folder2/anotherpage.html")
'http://www.asite.com/folder/folder2/anotherpage.html'
>>> resolvePath("http://www.asite.com/folder/currentpage.html", "/folder3/anotherpage.html")
'http://www.asite.com/folder3/anotherpage.html'
>>> resolvePath("http://www.asite.com/folder/currentpage.html", "../finalpage.html")
'http://www.asite.com/finalpage.html'
Para una RFC 3986 y el reemplazo cumple la norma Unicode, véase [ uritools] (http://pythonhosted.org/uritools/). – Marian
Esto no funciona si el segundo componente es absoluto, lamentablemente. Por ejemplo, 'urljoin (" http://example.com/blah.html "," ./././ whoa.html ")' * does * elimina los puntos, mientras que 'urljoin (" http: // example .com/blah.html "," /./././ whoa.html ")' no. – obskyr