8

I am using this code in my website to show Google search results for my website :

<!-- Search block -->       
<div class="searchBox">
    <form method="get" action="http://www.google.com/search"> 
        <input type="text" name="query" class="searchField" />
        <input type="hidden" name="sitesearch" value="my_website.com">
        <input type="submit" value="" class="searchSubmit">
    </form>
</div>  

I like that simple code and i do not prefer to use Google Custom Search, but is there a way to show the output of this search embedded in a page i specify ?

GrahamS
  • 9,980
  • 9
  • 49
  • 63
Brad
  • 4,457
  • 10
  • 56
  • 93

4 Answers4

7

Bing has a much better terms of use and an excellend API when it comes to site search integration.

It lets you take the XML that is returned and pretty much do whatever you want with it as long as you reference that your search is being powered by Bing somewhere in the result list.

Checkout my post here http://www.foliotek.com/devblog/integrating-bing-search-results-within-a-web-app-using-net/.

As far as Google results your only option is to use there built in frameing. The fully custom search cost were super high when I looked to do it behind SSL. For more information on Google Custom Search go here http://www.google.com/cse/.

Real World Bing Example A: http://www.mshsaa.org/Search/?q=basketball

bigamil
  • 657
  • 4
  • 12
  • I have no problem using Bing. But is this Java code or what ? :) – Brad Apr 05 '12 at 13:12
  • The blog post code is written in C#. Bing basically returns an XML document to you when you make a call to their API. Then its pretty much up to you to take that xml document parse it and build your custom results screen. Do you follow me? – bigamil Apr 05 '12 at 13:29
  • Yes, i do. I understand that. I am using PHP ... The final XML file path is "completeUri ", right ? I will try to parse it using PHP. – Brad Apr 05 '12 at 13:43
  • It should be completUri, however Bing just announced they will start to charge for their Bing search API ~$40 per month. Seems ridiculous IMO http://www.seroundtable.com/bing-search-api-paid-15015.html – bigamil Apr 30 '12 at 21:42
  • I found Bing much more reasonable and easier to integrate too. – acarlon Nov 05 '13 at 21:51
  • Please make sure to read Bings latest User Agreement, they have limited the use of their APIs and its not as wide open as it was when I originally answered this question. – bigamil Nov 19 '13 at 20:52
2

You could read the content from the page with file_get_contents and than read out the parts you need and display them on your page.

http://php.net/manual/en/function.file-get-contents.php

Maarten Kuilman
  • 481
  • 2
  • 6
  • 21
2

Looking at the terms and services for Google CSE (at the time of writing this):

1.3 Your Obligations. You shall receive a Query from the End User and shall forward that Query to Google. You may not in any way frame, cache or modify the Results produced by Google, except as otherwise agreed to between You and Google.

Seems to imply that I have to show the search results in the standard google page and not my own. Will look at Bing.

acarlon
  • 16,764
  • 7
  • 75
  • 94
1

You could use the argument igu=1

Example: Do you want to embedd the results of "Adelle"

Your URL shoud look like this: https://www.google.com/search?igu=1&q=Adelle, where q=Adelle is the query you want to search and igu=1 is set to allow iframe embedding.

Run the code snippet to see the result:

iframe {
width: 400px;
height: 200px;
border: 1px solid black;
border-radius: 5px;
}
With igu=1: <iframe src="https://www.google.com/search?igu=1&q=Adelle"></iframe>
<br>Without igu=1: <iframe src="https://www.google.com/search?q=Adelle"></iframe>
Martí Climent
  • 407
  • 4
  • 9