Click here to Skip to main content
Click here to Skip to main content

Search Your Website with MSN Search

, 4 Jul 2005
Rate this:
Please Sign up or sign in to vote.
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

Share

About the Author

Jason Witty
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? Pinmemberfernanda zettel26-Jul-10 12:27 
How do I highlight the searchterm in the search results?
 
It would be a great addition to this code if we could highlight or bold the keyword searched for in the search results, like this:
[^]
 
If someone finds out a way to do it, please let me know!
Thanks! Smile | :)
GeneralAwsome Pinmemberklack10725-Mar-08 12:47 
GeneralRe: Awsome PinmemberJason Witty25-Mar-08 13:55 
GeneralRe: Awsome Pinmemberklack10725-Mar-08 13:58 
GeneralRe: Awsome PinmemberJason Witty25-Mar-08 14:24 
GeneralRe: Awsome Pinmemberklack10725-Mar-08 14:43 
GeneralRe: Awsome PinmemberJason Witty25-Mar-08 14:55 
Generalnew version. PinmemberJason Witty2-Mar-08 13:11 
GeneralNice work!!! PinmemberAdamNThompson18-Sep-07 12:36 
GeneralDisplaying Page Numbers Pinmemberameer123456789011-Jan-07 23:56 
GeneralMSN Search Component Pinmembertcfialho5-Jan-07 16:12 
GeneralVery Good, Thanks Pinmemberdafepi20049-Dec-06 6:25 
GeneralYour Site PinsussAnonymous13-Jul-05 5:39 
GeneralRe: Your Site Pinmembermobileplanet13-Jul-05 6:58 
QuestionLegal? PinmemberThomas Lykke Petersen4-Jul-05 12:38 
AnswerRe: Legal? PinmemberJason-Witty4-Jul-05 15:19 
GeneralRe: Legal? PinmemberThomas Lykke Petersen5-Jul-05 2:52 
GeneralRe: Legal? PinsussJason Witty5-Jul-05 7:44 

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

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

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.141223.1 | Last Updated 4 Jul 2005
Article Copyright 2005 by Jason Witty
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid