Searching a website using Google Site Search without visiting Google

Have you ever complained that a web site you are visiting has a unreliable embedded search engine? Google allows you to search any website using “site:URL SEARCH_TERM” where URL is URL of the website and SEARCH_TERM is what you are looking for. This works way better than the search engines provided by most websites.

Imagine, for a moment, that you are visiting a website and want to search for something. It will be nice if we have a way of searching the website using Google due to the number of incorrect entries returned when using the website’s embedded search engine. What if we have a simple item on the bookmark bar which pops up a dialog that allows you to search the website using Google without visiting Google at all?

https://appleclinic.wordpress.com

It is easy to do this in Safari. Go to the bookmarks bar and click on the ‘Show all bookmarks’ icon.

Picture 1

Create a new bookmark with the following code as the address:


javascript:Qr=prompt('Search%20Site%20for','');
if(Qr)location.href='http://www.google.com/search
&q=site:'+encodeURIComponent(window.location.hostname)+'+'+escape(Qr)

Note: The code above should appear as a single line. Remove all line feeds.

Picture 2

You can name it “Site Search”.

Now, visit your favorite site. Click on the ‘Site Search’ bookmark bar item. The search window will show up. Type your search term and click ok. You should see a Google page with search results for the website.

This method should work with any browser that has proper JavaScript support.

Advertisements

About this entry