Monday, May 07, 2007

Smart Search tip for FireFox users

I know what some of you are going to say, "Dude! You and Firefox? I thought you were an Opera Die hard." I admit, I have finally switched to Firefox from opera. Whatever the reasons, I don't want to spark another one of those famous browser wars here.

Today's stuff is about smart searching. When you want to search something on a site you have to open the website's search page and then type in a query. That means u gotta see the same ol' page each and every time. Modern browsers have those little search bars to avoid loading the search page and take you directly to the search results.

Here, I will show the way to add your favorite websites to that search box in Firefox. I will use MSDN search as an example here. You have to first find out the search URL for the site. for that you simply open the website, put in a search query and reach the result page. Copy the resulting URL from the address bar.

Like if I search 'HELLO' on MSDN i get -

http://search.msdn.microsoft.com/search/Default.aspx?brand=msdn&locale=en-us&query=HELLO


Lets' analyze this URL-

  1. Locate the query string is ('HELLO' in this case is at the end like 'query=HELLO') If you change 'HELLO' to something else and press enter you will see that the results are changed appropriately.
  2. There are two parts in the URL. One is the search template and the second is the list of parameters after that URL.
  3. The search URL is 'http://search.msdn.microsoft.com/search/Default.aspx'. i.e the part before the first question mark.
  4. The Parameter List is "brand=msdn","locale=en-us","query=HELLO" i.e after the question mark.
  5. In the parameter list there are parameter/value pairs, each separated with a ampersand.
  6. Notice in the parameter list there will we a param/value pair in which the value is the search query. i.e "query=HELLO"

So, the total data we have is-

  • Name of site=MSDN
  • Description=MSDN Search
  • Search template=http://search.msdn.microsoft.com/search/Default.aspx
  • Parameters-
    • brand=msdn
    • locale=en-us
    • query=HELLO
  • Search Parameter whose value we need to change=query.

Now the procedure to add this to firefox is-

1. Create a XML file in [firefox install folder]\searchplugins . i.e MSDNSearch.xml

2. Use the template
<searchplugin xmlns="http://www.mozilla.org/2006/browser/search/">
<shortname>[Name of site]</shortname>
<description>[Description]</description>
<inputencoding>UTF-8</inputencoding>
<url type="text/html" method="GET" template="[search template]">
<param name="[Param1]" value="[Param1Value]">
...
<param name="[Param2]" value="[Param2Value]">
<param name="[Search Param]" value="{searchTerms}">
</url>
</searchplugin>
3. Fill the values. (MSDN example)
<searchplugin xmlns="http://www.mozilla.org/2006/browser/search/">
<shortname>MSDN</shortname>
<description>MSDN Search</description>
<inputencoding>UTF-8</inputencoding>
<url type="text/html" method="GET"
template="http://search.msdn.microsoft.com/search/Default.aspx">
<param name="brand" value="msdn">
<param name="locale" value="en-us">
<param name="query" value="{searchTerms}">
</url>
</searchplugin>
4. Save the file and restart firefox.

5. Now select the item from the search engine list and type in a query to test.


Another example using TorrentSpy -

<SearchPlugin xmlns="http://www.mozilla.org/2006/browser/search/">
<ShortName>TorrentSpy</ShortName>
<Description>TorrentSpy Search</Description>
<InputEncoding>UTF-8</InputEncoding>
<Url type="text/html" method="GET" template="http://www.torrentspy.com/search">
<Param name="query" value="{searchTerms}"/>
</Url>
</SearchPlugin>

Happy Searching...