Looking for php libary that correct url`s of a html page -


this question has answer here:

i'm making kind of proxy. php script downloads webpage , shows downloaded content. output doesn't original webpage because url's needs corrected (css, links, images, etc). i'm looking libary gets html elements src , href attributes can change value. example:

<link href="/images/favicon.ico"> 

needs changed to

<link href="http://example.com/images/favicon.ico"> 

what best way this?

<?php require_once('controller/simple_html_dom.php'); $str = '<link rel="stylesheet" type="text/css" href="/css/normalize.css?stillnospring"/>         <script type="text/javascript" src="/js/heyoffline.js?stillnospring"></script>';  $html = str_get_html($str); foreach($html->find('link[rel=stylesheet]') $stylesheets) {     echo $stylesheets->getattribute('href')."<br/>"; }  foreach($html->find('script[type=text/javascript]') $scripts) {     echo $scripts->getattribute('src')."<br/>"; } ?> 

you following links

/css/normalize.css?stillnospring /js/heyoffline.js?stillnospring 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -