Dom解析器和谷歌图像结果


Dom parser and Google image results

我试图检索谷歌图像结果/链接与php dom解析器。我刚刚写的代码运行没有错误,但我没有看到任何结果(即链接)输出到我的浏览器。你能帮我找出问题所在吗?我想不出来。

下面是我的脚本:
<?php
    include_once __DIR__.'/simple_html_dom.php';
    $name = '"michael jackson"';
    $query = urlencode($name); 
    $url = "https://www.google.com/search?q={$query}&tbm=isch&tbs=ic:color,isz:lt,islt:4mp,itp:face,isg:to";
    // Create DOM from URL or file
    $html = file_get_html($url);
    // Find all images
    $linkObjs = $html->find("div[class=rg_di rg_el ivg-i] a");
    foreach ($linkObjs as $linkObj) {
        $link = trim($linkObj->href);
        echo $link . '<br>';
    }
?>

在浏览器中(经过处理的)得到的DOM结构与普通html得到的DOM结构不同。输出$html的内容,您将看到。你需要调整你的选择器