php - Changing relative URLs of Javascript files -
i'm screen scraping using curl this:
<?php $url = "http://www.bbc.com/news/"; $ch = curl_init($url); curl_setopt($ch, curlopt_returntransfer, true); $curl_scraped_page = curl_exec($ch); curl_close($ch); echo $curl_scraped_page; ?> and echo content on html page. problem when in console see 404 errors because of relative urls assigned javascript files. instance if url is: somejavascriptfile.js on loading page domain name added so: http://mydomain/somejavascriptfile.js these paths not correct.
so can actual url of js file instead? if urls in body use jquery (split/replace) alter wouldn't work in case.
you can add base tag scraped html.
open html parser tidy, go start of head section , append <base> tag. base tag redirect resource access known location .
Comments
Post a Comment