I’m trying to retrieve images from any site that has images I’m using simplehtmldom lib in php to scrap the HTML page that the user chose and get only the images of that site ,
some site the lib manage to get the images bug allot of sites it doesn’t.it just
get empty result for example this site : http://www.outfitfashion.com/
I’m trying to get this image :
http://www.outfitfashion.com/images/lifestyle/SS12/home.jpg
and its never get it
$url = $urlname;
$html = file_get_html($url);
$counter = 0;
$strTmp ="";
foreach($html->find('img') as $element) {
$strTmp = url_to_absolute($url, $element->src);
$pattern0 = "/\.(?=jpg|gif|png|jpeg|bmp)/i";
if(preg_match($pattern0,$strTmp))
{
$user_albums_photos[$counter] = $strTmp;
$counter++;
}
}
$comma_separated = implode(",", $user_albums_photos);
Is there a better way? May be other libs in php that can handle complex HTML pages.
It is not picking it up because the image is set as a CSS
backgroundproperty to the<div>and not within an<img />tag. So there is nosrc=""attribute.If you want to pick up backgrounds you should look inside the
<head>tags for the style sheets then check through them.