At most sites, can work well when using the code below: <?php include "simple_html_dom.php"; $url = $_POST[url]; $html = file_get_html($url); foreach($html->find('img') as $element) echo '<img src='.$element->src.'><br>'; ?> PHP: But for some sites, I do not get the "src" with the correct url. For example: $ url = http://www.example.com and/or $ url = http://www.example.com/article/detail-of-article.html I can not display the image because in the "src" I just get a format like this: images/photo-1.jpg images/photo-2.jpg images/photo-3.jpg and/or ../images/photo-1.jpg ../images/photo-2.jpg ../images/photo-3.jpg Help me, friends...
The dom is working fine. It's just the way some websites are written. When making internal links to pages and directories on the same domain, certain web authors use relative filepaths instead of the full httpwww... You need to check each of the links to see whether or not its a valid url, and prepend the domain name and any directories in place of "../"
Hi. Is there a friend who can help me, how to make the code for the above problem? please help me... thanks in advance...
try adding <?php include "simple_html_dom.php"; $url = $_POST; $html = file_get_html($url); ...site.com/images/'.$element->src.'\"><br>'; ?>