MSN Live Search Result Grabber

By  on  

Within the last month, I've created two popular SEO tools: Google Grabber and Yahoo Grabber. Each grabber goes to the respective website and retrieves the number of pages a specified domain has indexed in the search engine. Having the indexed number of pages so quickly and easily is invaluable and a great sales tool.

Though MSN Live Search isn't a powerhouse search engine / portal, I thought I'd throw in the effort to put one together for Microsoft's search engine.

The PHP Code

/* return result number */
function get_msn_results($domain = 'davidwalsh.name')
{
	// get the result content
	$content = file_get_contents('http://search.msn.com/results.aspx?q=site%3A'.$domain);

	// parse to get results
	$pages = get_match('/id="count">(.*)</span>/isU',$content);

	//explode, get rid of "of"
	$pages = explode('of ',$pages);

	$return['pages'] = $pages[1] ? $pages[1] : 0;

	// return result
	return $return;
}

/* helper: does the regex */
function get_match($regex,$content)
{
	preg_match($regex,$content,$matches);
	return $matches[1];
}

The Usage

$domains = array('davidwalsh.name','digg.com','msn.com','cnn.com','dzone.com','some-domain-that-doesnt-exist.com');
foreach($domains as $domain)
{
	$result = get_msn_results($domain);
	echo $domain,': ',$result['pages'],'<br />';
}

//davidwalsh.name: 431
//digg.com: 9,610,000
//msn.com: 28,100,000
//cnn.com: 17,100,000
//dzone.com: 138,000
//some-domain-that-doesnt-exist.com: 0

Recent Features

  • By
    Responsive Images: The Ultimate Guide

    Chances are that any Web designers using our Ghostlab browser testing app, which allows seamless testing across all devices simultaneously, will have worked with responsive design in some shape or form. And as today's websites and devices become ever more varied, a plethora of responsive images...

  • By
    5 More HTML5 APIs You Didn&#8217;t Know Existed

    The HTML5 revolution has provided us some awesome JavaScript and HTML APIs.  Some are APIs we knew we've needed for years, others are cutting edge mobile and desktop helpers.  Regardless of API strength or purpose, anything to help us better do our job is a...

Incredible Demos

  • By
    CSS content and attr

    CSS is becoming more and more powerful but in the sense that it allows us to do the little things easily.  There have been larger features added like transitions, animations, and transforms, but one feature that goes under the radar is generated content.  You saw a...

  • By
    MooTools &#038; Printing &#8211; Creating a Links Table of Contents

    One detail we sometimes forget when considering print for websites is that the user cannot see the URLs of links when the page prints. While showing link URLs isn't always important, some websites could greatly benefit from doing so. This tutorial will show you...

Discussion

  1. Interesting that MSN turns up significantly more results for all my websites than Google does. Good work, David!

  2. I noticed that too Eric. MSN always turns up a whoooooole lot more than Goooooooogle.

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!