Get first image only on google image search

We use the following for the client to click to see images for the subject they have chosen. Works okay. I'd rather the display be in an iframe.

But the main problem is that we do not want to display all images, just 1 (or less than 5. ) Any based on the search criteria.  This should be done on the client side and be shown near the top of the resultant page.

Without getting into the Google Apps/API, and too technical, is there a simple way to ask Google to display only one or a few images, not the entire page? An entire page would simply be too much for the interface we prefer.
Here's what we're currently using.

 <a href="https://www.google.com/search?as_st=y&tbm=isch&as_q=&as_epq=<cfoutput>#UCASE(NewName)#</cfoutput>&as_oq=&as_eq=&cr=&as_sitesearch=&safe=active&tbs=isz:lt,islt:qsvga,itp:photo,ift:jpg&gws_rd=ssl" target="_blank"><cfoutput>#UCASE(NewName)#</cfoutput> IMAGES</a>
<hr />

Any suggestions?
Grover McBroomAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

skijCommented:
Is there any reason why you have to use Google Search for this?  Why not Flickr?
0
skijCommented:
There is no way to limit the number of results displayed on a standard Google Image search results page, however you could use the Google Image Search API and have full control.

In the example below, change the search query by adding the query to the end of the URL, for example:
page.html?smile

<!DOCTYPE html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>South Area Network</title>
<link href="css/new_style.css" rel="stylesheet" type="text/css" />

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.js" type="text/javascript"></script>
<script type="text/javascript">

$(document).ready(function(){
 var q = 'vervet monkey';
 results=5;
 if(location.search) q=unescape(location.search);
 $.getScript('https://ajax.googleapis.com/ajax/services/search/images?callback=processResults&rsz='+results+'&v=1.0&q='+escape(q));
});

function processResults(data){
$.each(data.responseData.results, function (i, data) {
 $('#gImages').append('<a href="'+data.originalContextUrl+'" target="_blank"><img src="https://encrypted-tbn1.gstatic.com/images?q=tbn:'+data.imageId+'" alt="'+data.titleNoFormatting+'" title="'+data.titleNoFormatting+'" /><a>');
});

}

</script>
</head>

<body>

<h1>Image Results</h1>

<div id="gImages"></div>

</body>
</html>
		

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Grover McBroomAuthor Commented:
If this is server side, then Google may limit these sort of requests as there may be several hundred or more per day.

My knowledge and skill are both limited.  I assume this function is client side and that Google will see it as a client request???

I prefer Google because the search is for current news and current events, not general photos.

If this works as client side, this was an excellent solution, works great with ColdFusion.  In any event, it's great. Thank you! Helps lots.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

skijCommented:
The code provided is client-side, not server-side code. Google will see the request as coming from your visitors, not your server.   The quota is 10,000 queries per day per unique IP address, and because it is client-side code, the quota applies to your visitors, not your website.  Even if one of your visitors ran 10,000 queries in a day, your other visitors would not be affected.
0
Grover McBroomAuthor Commented:
That's  fantastic. Thanks again, great service, great knowledge.
0
Alkin VeysalCommented:
Use simple_html_dom.php from http://simplehtmldom.sourceforge.net/ 
example:
include('simple_html_dom.php');
$search_keyword= $_GET['name'];
$search_keyword=str_replace(' ','+',$search_keyword);
$newhtml =file_get_html("https://www.google.com/search?q=".$search_keyword."&tbm=isch&gws_rd=cr&ei=16E0WMGSKYmisAHmp6b4Ag");
$result_image_source = $newhtml->find('img', 0)->src;
echo '<img src="'.$result_image_source.'"><br>';
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Images and Photos

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.