I am trying to retrieve Google image results/links with php dom parser. The code I have just written run without error, but I do not see any results( i.e. links) outputting to my browser. Can you help me find out the problem? I cannot figure out.
Here is my script:
<?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>';
}
?>