Error message

Deprecated function: The each() function is deprecated. This message will be suppressed on further calls in menu_set_active_trail() (line 2405 of /var/www/drupal/includes/menu.inc).

Downloading first google image result

How to download an image from google:

def getimageurlfromgoogle(query)
response = Net::HTTP.get_response('ajax.googleapis.com',
URI.encode("/ajax/services/search/images?v=1.0&q=#{query}&as_filetype=png&safe=active"))
JSON.parse(response.body)["responseData"]["results"][0]["url"]
end

The first result is not always the best result!!