Convert a relative URL to an absolute URL with Simple HTML DOM?

后端 未结 3 854
青春惊慌失措
青春惊慌失措 2020-12-16 07:58

When I\'m scraping content from some pages, the script gives a relative URL. Is it possible to get a absolute URL with Simple HTML DOM?

3条回答
  •  佛祖请我去吃肉
    2020-12-16 08:25

    In addition to @Artefacto's answer, and if you are outputting the scraped HTML somewhere, you could simply add to the head of the document, which will establish the base URL for all relative URLs in the document as the specified href. Have a look at http://www.w3schools.com/tags/tag_base.asp

提交回复
热议问题