I am scraping HTML using SimpleHtmlDom which gets the HTML as written, resulting in a lot of broken links to images and scripts because they do not include the full url to their resource location. Consequently the pages show with errors.
I have already corrected resource links like src="/, etc by replacing those letters with src="http://example.com/" but it gets tricky when there is no leading slash in the link, making it difficult to tell if it is a local link or a full link.
For example:
<img src="images/pic.jpg">
I need to locate and correct to read:
<img src="http://example.com/images/pic.jpg">
Is there a regex or function that I can use to I find src=" when there is no leading slash? Also need to cater for all types of links such as ahref, script, etc.