Grover McBroom
asked on
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(New Name)#</cf output>&as _oq=&as_eq =&cr=&as_s itesearch= &safe=acti ve&tbs=isz :lt,islt:q svga,itp:p hoto,ift:j pg&gws_rd= ssl" target="_blank"><cfoutput> #UCASE(New Name)#</cf output> IMAGES</a>
<hr />
Any suggestions?
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(New
<hr />
Any suggestions?
Is there any reason why you have to use Google Search for this? Why not Flickr?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
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.
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.
ASKER
That's fantastic. Thanks again, great service, great knowledge.
Use simple_html_dom.php from http://simplehtmldom.sourceforge.net/
example:
include('simple_html_dom.p hp');
$search_keyword= $_GET['name'];
$search_keyword=str_replac e(' ','+',$search_keyword);
$newhtml =file_get_html("https://www.google.com/search?q=".$search_ keyword."& tbm=isch&g ws_rd=cr&e i=16E0WMGS KYmisAHmp6 b4Ag");
$result_image_source = $newhtml->find('img', 0)->src;
echo '<img src="'.$result_image_sourc e.'"><br>' ;
example:
include('simple_html_dom.p
$search_keyword= $_GET['name'];
$search_keyword=str_replac
$newhtml =file_get_html("https://www.google.com/search?q=".$search_
$result_image_source = $newhtml->find('img', 0)->src;
echo '<img src="'.$result_image_sourc