From Google Blogoscoped:
Google updated their Google Images search result output a while ago. Here’s a piece of PHP5 that screen-scrapes the result for your personal use. For example, this sample search engine grabs an array of Google image results using the getGoogleImages() function, and then outputs it again on a blank page; it will allow you to right-click a particular thumbnail to zoom into its full size.

<?
header("Content-type: text/html; charset=utf-8");
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Get Images</title>

</head>
<body>

<?

$results = getGoogleImages('horses');
foreach ($results as $result) {
    echo '<p><a href="' . htmlentities($result['url']) . '">' .
            '<img src="' . htmlentities($result['thumbnail']) . '" alt="" ' .
            'oncontextmenu="this.src=\'' . htmlentities($result['image']) . '\';return false;" ' .
            'style="border: 1px solid black" /></a><br />' .
            '<em>' . htmlentities($result['description']) . '</em>' .
            '</p>';
}

?>

</body>
</html><?

function getGoogleImages($q, $doSafeSearch = false)
{
    $results = array();

    $safe = ($doSafeSearch) ? 'on' : 'off';
    $url = 'http://images.google.com/images?safe=' . $safe .
            '&q=' . urlencode($q);
    $result = file_get_contents($url);

    $from = 'dyn.Img("';
    $startPos = strPos($result, $from);
    $endPos = strPos($result, ');dyn.updateStatus');
    $functions = substr( $result, $startPos + strlen($from), $endPos );
    $functions = explode('");dyn.Img("', $functions);

    foreach ($functions as $f) {
        $i = count($results);
        list($results[$i]['url'], $v1, $hash,
                $results[$i]['image'],
                $results[$i]['width'], $results[$i]['height'],
                $results[$i]['description'],
                $v2, $v3, $more, $extension, $domain) = explode('","', $f);
        list($results[$i]['url'], $params) = explode('&h', $results[$i]['url']);

        $prefix = 'http://tbn0.google.com/images?q=tbn:';
        $results[$i]['thumbnail'] = $prefix . $hash . ':' . $results[$i]['image'];
        $results[$i]['description'] = strip_tags($results[$i]['description']);
    }

    return $results;
}

?>

The Google HTML output delivers image information in the JavaScript portion. This means that, as in the example above, it’s very easy to split the string into its sub parts like description, original page URL, thumbnail and so on.

Google Blogoscoped have a very simple sample page.

Of course nothing goes to plan – My host has disabled file_get_contents for url’s. I got round it by using curl. Search for the lines containing file_get_contents, to see the start / end of the modification. I picked the appropriate variable names, so that the changed code replaces the line containing file_get_contents.

Reading: Screen-scraping Current Google ImagesTweet This