Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Search Your Website with MSN Search

0.00/5 (No votes)
4 Jul 2005 2  
Use MSN search RSS results to display site specific search results on your own website.

Sample Image

Introduction

When the new MSN search was launched it didn't take me long to notice the RSS button at the bottom of each search result listing. At first I thought the notion was completely absurd. In all honesty I could not think of any good reason to subscribe to search results in an RSS reader or you mail client. As I investigated a little bit more, I noticed that the results were driven by the query string and that I could in fact adjust my results by adjusting the query string. I quickly realized that you could include MSN search results in your application or web site by aggregating this data. Like Google search, MSN supports the search word "site:yoursite.com", so by combining these two features you can create a search engine for your own site using MSN's results.

Background

In the example above, I am building the query string on the fly with the search string typed in my web form. I then parse the RSS feed with an XSL style sheet and display the results. The pagination is accomplished by passing parameters to the XSL file and handling the pagination within the XSL. To view this example, click the link above.

Using the code

As you can see, the search works very well and is very fast. You can try searching my site for something like "ASP" or "XML" to generate a sufficient amount of search results.

I am making my code available for download. Please feel free to download it and use it on your site. It will work on any server that will run ASP.NET. There are only two variables that you need to change to personalize the search results in your site. In the ASPX file, you will find two variables "sitename" and "resultcount". sitename is the fully qualified domain name of your site and resultcount specifies the total number of results to return. You may want to adjust this based on the amount of content you have. The less total results you download on each query, the faster it will run.

Points of Interest

Also though it may be difficult for Microsoft to track where its feed is being used, the licensing information within the RSS file specifically states that the results are not to be used for commercial purposes. As I understand Google API is free for all for up to 1,000 searches per day. So if you are building a commercial web site, I would recommend using the Google search API, but if you are just looking to implement a great quick search on your personal web site, then MSN site search is a great choice. If you do decide to use this script on your web site, please post a link so I can take a look.

History

  • 6/7/2005 - Released.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here