How i can extract all images links? I would do something like : excade('img src',$webpage)... but i am afraid an crazy coder could code something like img border=0 scr='image.jpg' , and it will mess everything up... So how i can extact all images urls in a smart way , using preg_match , to get something like img*src?
Assuming you have html page content in $html; $dom = new DOMDocument(); @$dom->loadHTML($html); // grab all the on the page $xpath = new DOMXPath($dom); $imgs = $xpath->evaluate("/html/body//img"); foreach ($imgs as $img) { $image = $img->getAttribute('src'); echo "<br />image: $image"; } PHP: