如何过滤广告图像时,使用'简单的html dom '获取网站's图像


How to filter ads images when use `simple html dom` get site's images

我想使用simple_html_dom获得一些网站的图像。这是一个试验场。当我使用下面的一些基本代码时,我可以得到所有的图像。但是如何过滤广告图像呢?

<?php
header('Content-type:text/html; charset=utf-8');
require_once 'simple_html_dom.php';
$v = 'http://www.vimeo.com/';
$html = file_get_html($v);
foreach($html->find('img') as $element) {
            $image = $element->src;
            echo '<img src="'.$image.'" /><hr />';
        }
?>

我注意到一些广告也作为jpg image format,但url包含adads,或一些东西就像gif image format…如何编写一些代码来过滤广告?谢谢。

如果找到ad(s)字符串,在src中搜索。但那可能性太大了,像admin, address, reading

if (!preg_match("ads?", $element->src)) {
    //it's not an ad
}