Reconstructing absolute urls from relative urls on a page

后端 未结 2 770
逝去的感伤
逝去的感伤 2020-12-30 23:18

Given an absolute url of a page, and a relative link found within that page, would there be a way to a) definitively reconstruct or b) best

2条回答
  •  被撕碎了的回忆
    2020-12-30 23:50

    very simple:

    >>> from urlparse import urljoin
    >>> urljoin('http://mysite.com/foo/bar/x.html', '../../images/img.png')
    'http://mysite.com/images/img.png'
    

提交回复
热议问题