Google Hacks Free Open Book

Google Hacks

Previous Section Next Section

Hack 79 Measuring Google Mindshare

figs/moderate.giffigs/hack79.gif

Measure the Google mindshare of a particular person within a query domain.

Based on an idea by author Steven Johnson (http://www.stevenberlinjohnson.com), this hack determines the Google mindshare of a person within a particular set of Google queried keywords. What's Willy Wonka's Google mindshare of "Willy"? What percentage of "weatherman" does Al Roker hold? Who has the greater "The Beatles" Google mindshare, Ringo Starr or Paul McCartney? More importantly, what Google mindshare of your industry does your company own?

Google mindshare is calculated as follows: determine the size of the result set for a keyword or phrase. Determine the result set size for that query along with a particular person. Divide the second by the first and multiply by 100, yielding percent Google mindshare. For example: A query for Willy yields about 1,590,000 results. "Willy Wonka" +Willy finds 66,700. We can conclude—however unscientifically—that Willy Wonka holds roughly a 4% (66,700 / 1,590,000 x 100) Google mindshare of Willy.

Sure it's a little silly, but there's probably a grain of truth in it somewhere.

79.1 The Code

#!/usr/local/bin/perl
# google_mindshare.cgi
# This implementation by Rael Dornfest
# http://www.raelity.org/lang/perl/google/googleshare/
# Based on an idea by Steven Johnson
# http://www.stevenberlinjohnson.com/movabletype/archives/000009.html

# Your Google API developer's key
my $google_key='insert key here';

# Location of the GoogleSearch WSDL file
my $google_wdsl = "./GoogleSearch.wsdl";

use SOAP::Lite;
use CGI qw/:standard *table/;

print
  header(  ),
  start_html("Googleshare Calculator"),
  h1("Googleshare Calculator"),
  start_form(-method=>'GET'),
  'Query: ', br(  ), textfield(-name=>'query'),
  p(  ),
  'Person: ',br(  ), textfield(-name=>'person'),
  p(  ),
  submit(-name=>'submit', -value=>'Calculate'),
  end_form(  ), p(  );

if (param('query') and param('person')) {
  my $google_search  = SOAP::Lite->service("file:$google_wdsl");

  # Query Google for they keyword, keywords, or phrase
  my $results = $google_search ->
    doGoogleSearch(
      $google_key, '"'.param('query').'"', 0, 1, "false", "",  "false",
      "", "latin1", "latin1"
    );

  # Save the results for the Query
  my $query_count = $results->{estimatedTotalResultsCount};

  my $results = $google_search ->
    doGoogleSearch(
      $google_key, '+"'.param('query').'" +"'.param('person').'"', 0, 1,
      "false", "",  "false", "", "latin1", "latin1"
    );
  # Save the results for the Query AND Person
  my $query_person_count = $results->{estimatedTotalResultsCount};

  print
    p(
      b(sprintf "%s has a %.2f%% googleshare of %s",
        param('person'),
        ($query_person_count / $query_count * 100),
        '"'.param('query').'"'
      )
    )
}

print end_html(  );

79.2 Running the Hack

Visit the CGI script in your browser. Enter a query and a person. The name doesn't necessarily have to be a person's full name. It can be a company, location, just about any proper noun, or anything, actually. Click the "Calculate" button and enjoy. Figure 6-20 shows the Willy Wonka example.

Figure 6-20. Google mindshare for Willy Wonka
figs/gooH_0620.gif

79.3 Fun Hack Uses

You can't do too many practical things with this hack, but you can have a lot of fun with it. Playing "unlikely percentages" is fun; see if you can find a name/word combo that gets a higher percentage than other percentages you would consider more likely. Here are the answers to the questions posted at the beginning of this hack, and more:

  • Willy Wonka has a 4.82% Google mindshare of "Willy."

  • Al Roker has a 1.45% Google mindshare of "weatherman."

  • Ringo Starr has a 1.69% Google mindshare of "The Beatles."

  • Paul McCartney has a 3.71% Google mindshare of "The Beatles."

  • Red Hat has a 3.63% Google mindshare of "Linux."

  • Microsoft has a 4.37% Google mindshare of "Linux."

    Previous Section Next Section


         Main Menu
    Main Page
    Table of content
    Copyright
    Dedication
    Credits
    Foreword
    Preface
    Chapter 1. Searching Google
    Chapter 2. Google Special Services and Collections
    Chapter 3. Third-Party Google Services
    Chapter 4. Non-API Google Applications
    Chapter 5. Introducing the Google Web API
    Chapter 6. Google Web API Applications
    6.1 Hacks #60-85
    6.2 The Ingenuity of Millions
    6.3 Learning to Code
    6.4 What You'll Find Here
    6.5 Finding More Google API Applications
    6.6 The Possibilities Aren't Endless, but They're Expanding
    Hack 60 Date-Range Searching with a Client-Side Application
    Hack 61 Adding a Little Google to Your Word
    Hack 62 Permuting a Query
    Hack 63 Tracking Result Counts over Time
    Hack 64 Visualizing Google Results
    Hack 65 Meandering Your Google Neighborhood
    Hack 66 Running a Google Popularity Contest
    Hack 67 Building a Google Box
    Hack 68 Capturing a Moment in Time
    Hack 69 Feeling Really Lucky
    Hack 70 Gleaning Phonebook Stats
    Hack 71 Performing Proximity Searches
    Hack 72 Blending the Google and Amazon Web Services
    Hack 73 Getting Random Results (On Purpose)
    Hack 74 Restricting Searches to Top-Level Results
    Hack 75 Searching for Special Characters
    Hack 76 Digging Deeper into Sites
    Hack 77 Summarizing Results by Domain
    Hack 78 Scraping Yahoo! Buzz for a Google Search
    Hack 79 Measuring Google Mindshare
    Hack 80 Comparing Google Results with Those of Other Search Engines
    Hack 81 SafeSearch Certifying URLs
    Hack 82 Syndicating Google Search Results
    Hack 83 Searching Google Topics
    Hack 84 Finding the Largest Page
    Hack 85 Instant Messaging Google
    Chapter 7. Google Pranks and Games
    Chapter 8. The Webmaster Side of Google
    Colophon
    Index


    More Books
    PHP Hacks
    Processing Xml With Java - A Guide To Sax, Dom, Jdom, Jaxp, And Trax
    The Koran (Holy Qur'an)
    Macromedia Flash 8 Bible
    Search Engine Optimization for Dummies
    YouTube Traffic
    PHP 5 for Dummies
    Harry Potter and The Chamber of Secrets
    Harry Potter and the Sorcerer's Stone
    The Pilgrim's Progress
    Wireless Hacks
    Flash Hacks. 100 Industrial-Strength Tips & Tools
    PayPal Hacks. 100 Industrial-Strength Tips and Tools
    Amazon Hacks
    Pdf Hacks
    The Da Vinci Code
    Google Hacks
    The Holy Bible
    Windows XP For Dummies
    Harry Potter and the Half-Blood Prince
    Seo Book
    Upgrading and Repairing Networks
    Macromedia Dreamweaver 8 UNLEASHED
    Windows XP Annoyances
    Windows XP Hacks
    Microsoft Windows XP Power Toolkit
    Teach Yourself MS Office In 24Hours
    iPod & iTunes Missing Manual
    PC Hacks 100 Industrial-Strength Tips and Tools
    PC Overclocking, Optimization, and Tuning - 2th Edition
    PC Hardware In A Nutshell 3rd Edition
    PC Hardware in a Nutshell, 2nd Edition
    Upgrading and Repairing PCs
    Google for Dummies
    MySQL Cookbook
    Teach Yourself Macromedia Flash 8 In 24 Hours
    PHP CookBook
    Sams Teach Yourself JavaScript in 24 Hours
    PHP5 Manual
    Free Games Paper Airplanes
    500 Juegos Gratis 500 Giochi Gratis 500 Jeux Gratuits 500 Jogos Gratis 500 Kostenlose Spiele