Yahoo! Directory Mindshare in Google





Yahoo! Directory Mindshare in Google

How does link popularity compare in Yahoo!'s searchable subject index versus Google's full-text index? Find out by calculating mindshare!

Yahoo! and Google are two very different animals. Yahoo! indexes only a site's main URL, title, and description, while Google builds full-text indexes of entire sites. Surely there's some interesting cross-pollination when you combine results from the two.

This hack scrapes all the URLs in a specified subcategory of the Yahoo! directory. It then takes each URL and gets its link count from Google. Each link count provides a nice snapshot of how a particular Yahoo! category and its listed sites stack up on the popularity scale.

What's a link count? It's simply the total number of pages in Google's index that link to a specific URL.


There are a couple of ways you can use your knowledge of a subcategory's link count. If you find a subcategory whose URLs have only a few links each in Google, you may have found a subcategory that isn't getting a lot of attention from Yahoo!'s editors. Consider going elsewhere for your research. If you're a webmaster and you're considering paying to have Yahoo! add you to its directory, run this hack on the category in which you want to be listed. Are most of the links really popular? If they are, are you sure your site will stand out and get clicks? Maybe you should choose a different category.

We got this idea from a similar experiment done by Jon Udell (http://weblog.infoworld.com/udell) in 2001. He used AltaVista instead of Google; see http://udell.roninhouse.com/download/mindshare-script.txt. We appreciate the inspiration, Jon!

The Code

You will need a Google API account (http://api.google.com) as well as the Perl modules SOAP::Lite (http://www.soaplite.com) and HTML::LinkExtor (http://search.cpan.org/author/GAAS/HTML-Parser/lib/HTML/LinkExtor.pm) to run the following code. You'll also need a copy of the Google WSDL file in the same directory as the script (http://api.google.com/GoogleSearch.wsdl). Save the following code to a file called mindshare.pl:

	#!/usr/bin/perl -w
	
	use strict;
	use LWP::Simple;
	use HTML::LinkExtor;
	use SOAP::Lite;

	my $google_key = "your API key goes here";
	my $google_wdsl = "GoogleSearch.wsdl";
	my $yahoo_dir = shift || "/Computers_and_Internet/Data_Formats/XML_ _".
				"eXtensible_Markup_Language_/RSS/Aggregators/";

	# download the Yahoo! directory.
	my $data = get("http://dir.yahoo.com" . $yahoo_dir) or die $!;

	# create our Google object.
	my $google_search = SOAP::Lite->service("file:$google_wdsl");
	my %urls; # where we keep our counts and titles.
	# extract all the links and parse 'em.
	HTML::LinkExtor->new(\&mindshare)->parse($data);
	sub mindshare { # for each link we find…

		my ($tag, %attr) = @_;
		
		# only continue on if the tag was a link,
		# and the URL matches Yahoo!'s redirectory,
		return if $tag ne 'a';
		return if $attr{href} =~ /us.rd.yahoo/;
		return unless $attr{href} =~ /^http/;
	
		# and process each URL through Google.
		my $results = $google_search->doGoogleSearch(
				$google_key, "link:$attr{href}", 0, 1,
				"true", "", "false", "", "", ""
				); # wheee, that was easy, guvner.
		$urls{$attr{href}} = $results->{estimatedTotalResultsCount};
	}

		# now sort and display.
		my @sorted_urls = sort { $urls{$b} <=> $urls{$a} } keys %urls;
		foreach my $url (@sorted_urls) { print "$urls{$url}: $url\n"; }

Running the Hack

The hack has its only configurationthe Yahoo! directory you're interested inpassed as a single argument (in quotes) on the command line (if you don't pass one of your own, a default directory will be used instead):

	% perl mindshare.pl "/Entertainment/Humor/Procrastination/"

Your results show the URLs in those directories, sorted by total Google links:

	554: http://www.p45.net/
	339: http://www.ishouldbeworking.com/
	124: http://www.india.com/
	45: http://www.geocities.com/SouthBeach/1915/
	15: http://www.eskimo.com/~spban/creed.html
	15: http://www.jlc.net/~useless/
	5: http://www.black-schaffer.org/scp/
	2: http://www.angelfire.com/mi/psociety
	1: http://www.geocities.com/wastingstatetime/

Hacking the Hack

Yahoo! isn't the only searchable subject index out there, of course; there's also the Open Directory Project (DMOZ, http://www.dmoz.org), which is the product of thousands of volunteers busily cataloging and categorizing sites on the Webthe web community's Yahoo!, if you will. This hack works just as well on DMOZ as it does on Yahoo!; they're very similar in structure.

Replace the default Yahoo! directory with its DMOZ equivalent:

	my $dmoz_dir = shift || "/Reference/Libraries/Library_and_Information_
Science/". "Technical_Services/Cataloguing/Metadata/RDF/". "Applications/RSS/News_Readers/";

You'll also need to change the download instructions:

	# download the Dmoz.org! directory.
	my $data = get("http://dmoz.org" . $dmoz_dir) or die $!;

Next, replace the lines that check whether a URL should be measured for mindshare. When we were scraping Yahoo! in our original script, we skipped over Yahoo! links and those that weren't web sites:

	return if $attr{href} =~ /us.rd.yahoo/;
	return unless $attr{href} =~ /^http/;

Since DMOZ is an entirely different site, we'll make sure it's a full-blooded location (i.e., it starts with http//:) as before and that it doesn't match any of DMOZ's internal page links. Likewise, we'll ignore searches on other engines:

	return unless $attr{href} =~ /^http/;
	return if $attr{href} =~ /dmoz|google|altavista|lycos|yahoo|alltheweb/;

Can you go even further with this? Sure! You might want to search a more specialized directory, such as the FishHoo! fishing search engine (http://www.fishhoo.com).

You might want to return only the most linked-to URL from the directory, which is quite easy by piping the results to head, another common Unix utility:

	 % perl mindshare.pl | head 1

Alternatively, you might want to go ahead and grab the top 10 Google matches for the URL that has the most mindshare. To do so, add the following code to the bottom of the script:

	print "\nMost popular URLs for the strongest mindshare:\n";
	my $most_popular = shift @sorted_urls;
	my $results = $google_search->doGoogleSearch(
				$google_key, "$most_popular", 0, 10,
				"true", "", "false", "", "", "" );

	foreach my $element (@{$results->{resultElements}}) {
		next if $element->{URL} eq $most_popular;
		print " * $element->{URL}\n";
		print " \"$element->{title}\"\n\n";
	}

Then run the script as usual (the output here uses the default hardcoded directory):

	% perl mindshare.pl
	24600: http://www.newsburst.com/
	22700: http://www.bloglines.com/
	9640: http://radio.userland.com/
	6890: http://www.feedreader.com/
	4770: http://www.sharpreader.net/
	4660: http://www.newsgator.com/
	3580: http://www.newsisfree.com/
	2680: http://www.pubsub.com/
	2090: http://www.disobey.com/amphetadesk/
	1740: http://www.serence.com/site.php?page=prod_klipfolio	
	1690: http://www.pluck.com/
	1610: http://www.rssbandit.org/
	1160: http://www.allheadlinenews.com/
	1140: http://www.newzcrawler.com/
	961: http://www.rojo.com/
	
	…

	Most popular URLs for the strongest mindshare:
	* http://www.newsburst.com/Source/?add=PUTyourFEEDurlHERE
	  ""

	* http://deeplinking.net/xmlsrv/rss.php?blog=4
	  "Deeplinking"

	* http://www.bloglines.com/citations?url=http://www.newsburst.com
	  "Bloglines | Citations"

	* http://www.feedforall.com/forum/posting.php?mode=quote&p=624
	  "FeedForAll :: Post a reply"

	…

Kevin Hemenway and Tara Calishain



 Python   SQL   Java   php   Perl 
 game development   web development   internet   *nix   graphics   hardware 
 telecommunications   C++ 
 Flash   Active Directory   Windows