La résolution d'un chemin url relatif à son chemin d'accès absolu
Est-il une bibliothèque python qui fonctionne comme cela?
>>> 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'
Vous devez vous connecter pour publier un commentaire.
Oui, il y a
urlparse.urljoin
, ouurllib.l'analyser.urljoin
pour Python 3.pour copier-coller:
urljoin("http://example.com/blah.html", "./././whoa.html")
t supprimer les points, tandis queurljoin("http://example.com/blah.html", "/./././whoa.html")
ne l'est pas.