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
    From Webcam to Animated GIF: the Secret Behind chat.meatspac.es!

    My team mate Edna Piranha is not only an awesome hacker; she's also a fantastic philosopher! Communication and online interactions is a subject that has kept her mind busy for a long time, and it has also resulted in a bunch of interesting experimental projects...

  • By
    Create a CSS Flipping Animation

    CSS animations are a lot of fun; the beauty of them is that through many simple properties, you can create anything from an elegant fade in to a WTF-Pixar-would-be-proud effect. One CSS effect somewhere in between is the CSS flip effect, whereby there's...

Incredible Demos

  • By
    spellcheck Attribute

    Many useful attributes have been provided to web developers recently:  download, placeholder, autofocus, and more.  One helpful older attribute is the spellcheck attribute which allows developers to  control an elements ability to be spell checked or subject to grammar checks.  Simple enough, right?

  • By
    CSS @supports

    Feature detection via JavaScript is a client side best practice and for all the right reasons, but unfortunately that same functionality hasn't been available within CSS.  What we end up doing is repeating the same properties multiple times with each browser prefix.  Yuck.  Another thing we...

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!