I’ve been playing around with SimpleHTMLDOM Parser (http://simplehtmldom.sourceforge.net/) which is a great tool, however, I’ve been running into a problem collecting img elements from inside the body. This is best illustrated through an example:
Here are 2 URL’s of the same image. I run the following code on these URLS respectively:
$html = $this->DOMParser->file_get_html($url);
foreach($html->find('img') as $element){
print($element->src);
}
http://imageshack.us/photo/my-images/412/71banksy89789ll7.jpg/
(SHTMLD picks up the images here)
and
http://imageshack.us/scaled/landing/412/71banksy89789ll7.jpg
(SHTMLD picks up nothing)
I’ve tried for a few days now to figure out what’s going on, but the only different in this example would be in the html tags.
Any ideas?
Your second url is pointing to an jpeg file directly, instead of a html page holding img tags. SimpleHTMLDOM Parser can only parse html pages, so it won’t work when you fed it an image file instead of a html page.