Click here to Skip to main content
15,878,959 members
Articles / Web Development / IIS
Article

Search Your Website with MSN Search

Rate me:
Please Sign up or sign in to vote.
4.59/5 (18 votes)
4 Jul 20052 min read 64.7K   987   43   18
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


Written By
Software Developer (Senior)
United States United States
For more articles please visit my website:
http://www.aprogrammersjournal.com

A Programmers Journal
RSS

Comments and Discussions

 
QuestionHow do I highlight or bold the searchterm in the search results? Pin
fernanda zettel26-Jul-10 11:27
fernanda zettel26-Jul-10 11:27 
GeneralAwsome Pin
klack10725-Mar-08 11:47
klack10725-Mar-08 11:47 
GeneralRe: Awsome Pin
Jason Witty25-Mar-08 12:55
Jason Witty25-Mar-08 12:55 
GeneralRe: Awsome Pin
klack10725-Mar-08 12:58
klack10725-Mar-08 12:58 
GeneralRe: Awsome Pin
Jason Witty25-Mar-08 13:24
Jason Witty25-Mar-08 13:24 
GeneralRe: Awsome Pin
klack10725-Mar-08 13:43
klack10725-Mar-08 13:43 
GeneralRe: Awsome Pin
Jason Witty25-Mar-08 13:55
Jason Witty25-Mar-08 13:55 
Generalnew version. Pin
Jason Witty2-Mar-08 12:11
Jason Witty2-Mar-08 12:11 
GeneralNice work!!! Pin
AdamNThompson18-Sep-07 11:36
AdamNThompson18-Sep-07 11:36 
GeneralDisplaying Page Numbers Pin
ameer123456789011-Jan-07 22:56
ameer123456789011-Jan-07 22:56 
GeneralMSN Search Component Pin
tcfialho5-Jan-07 15:12
tcfialho5-Jan-07 15:12 
GeneralVery Good, Thanks Pin
dafepi20049-Dec-06 5:25
dafepi20049-Dec-06 5:25 
GeneralYour Site Pin
Anonymous13-Jul-05 4:39
Anonymous13-Jul-05 4:39 
GeneralRe: Your Site Pin
mobileplanet13-Jul-05 5:58
mobileplanet13-Jul-05 5:58 
QuestionLegal? Pin
Thomas Lykke Petersen4-Jul-05 11:38
Thomas Lykke Petersen4-Jul-05 11:38 
AnswerRe: Legal? Pin
Jason Witty4-Jul-05 14:19
Jason Witty4-Jul-05 14:19 
GeneralRe: Legal? Pin
Thomas Lykke Petersen5-Jul-05 1:52
Thomas Lykke Petersen5-Jul-05 1:52 
GeneralRe: Legal? Pin
Jason Witty5-Jul-05 6:44
Jason Witty5-Jul-05 6:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.