O'Reilly Hacks
oreilly.comO'Reilly NetworkSafari BookshelfConferences Sign In/My Account | View Cart   
Book List Learning Lab PDFs O'Reilly Gear Newsletters Press Room Jobs  



HACK
#87
Google Whacking
With over 2 billion pages in its index, is it possible to get only one result for a search?

Contributed by:

[03/13/03 | Discuss (134) | Link to this hack]

With an index of over 2 billion pages, Google attracts lots of interest from searchers. New methods of searching are tested, new ways of classifying information are explored, new games are invented.

New games are invented? Well, yes, actually. This is the Internet, after all.

The term "Google whacking" was coined by Gary Stock. The idea is to find a two-word query that has only one result. The two words may not be enclosed in quotes (that's too easy), and the words must be found in Google's own dictionary (no proper names, made-up words, etc). If the one result comes from a word list, such as a glossary or dictionary, the whack is disqualified.

If you manage a Google whack—and its harder than it sounds—be sure to list your find on the official Whack Stack (http://www.googlewhack.com/). Perusing the most recent 2,000 whacks is highly recommended if your brain is stuck and you need a little inspiration in your research. Examples include "endoscopy cudgels," "nebbish orthodontia," and "peccable oink."

Are you stuck for a Google whack query? This hack should help. It takes a random word from each of two "word of the day" sites and queries Google in hopes of a Google whack (or as experienced players would say, "To see if they make a whack").

#!/usr/local/bin/perl
# google_whack.pl
# An automated Google whacker.
# Usage: perl google_whack.pl

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

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

use strict;

# Use the SOAP::Lite and LWP::Simple Perl modules
use SOAP::Lite;
use LWP::Simple;

# Generate some random numbers to be used as dates for choosing 
# random word one.
srand(  );
my $year  = int( rand(2) ) + 2000;
my $month = int( rand(12) ) + 1; 
$month < 10 and $month = "0$month";
my $day = int( rand(28) ) +1;
$day < 10 and $day = "0$day";

# Pulling our first random word from Dictionary.com
my $whackone = 
  get("http://www.dictionary.com/wordoftheday/archive/$year/$month/$day.html") 
  or die "Couldn't get whack word 1: $!";
($whackone) = 
  ($whackone =~ /<TITLE>Dictionary.com\/Word of the Day: (.*)<\/TITLE>/i);

# Generate a new year between 1997 and 2000 for choosing
# random word two
srand(  );
$year  = int( rand(5) ) + 1997;

# Pulling our second random word from th  now defunct Maven's 
# Word of the Day (thank goodness for archives)
my $whacktwo = 
  get("http://www.randomhouse.com/wotd/index.pperl?date=$year$month$day") 
  or die "Couldn't get whack word 2:: $!";
($whacktwo) = ($whacktwo =~ m!<h2><B>(.*)</b></h2>!i);

# Build our query out of the two random words
my $query = "$whackone $whacktwo"; 

# Create a new SOAP::Lite instance, feeding it GoogleSearch.wsdl
my $google_search = SOAP::Lite->service("file:$google_wdsl");

# Query Google
my $results = $google_search -> 
    doGoogleSearch(
      $google_key, $query, 0, 10, "false", "",  "false",
      "", "latin1", "latin1"
    );

# A single result means a possible Google whack
if ($results->{'estimatedTotalResultsCount'} == 1) {
  my $result = $results->{'resultElements'}->[0];
  print 
    join "\n",
      "Probable Google whack for $query",
      "Title: " . $result->{title}||'no title',
      "URL: $result->{URL}",
      "Snippet: " . $result->{snippet}||'no title',
      "\n";
}

# Anything else is Google jack 
else {
  print "Google jack for $query, with " . 
    $results->{'estimatedTotalResultsCount'}  . " results\n";
}

  • whacked!
    2004-12-30 11:48:05  ballet [Reply | View]

    sesquepedalian kitten
  • google whack
    2004-12-29 07:30:25  elkrobber [Reply | View]

    i got one!
    numatic osteopath
  • I got one!
    2004-12-28 08:58:32  AHCgooglewhack [Reply | View]

    I got a two word phrase that only comes up with one result, it is "preromanticism pyromaniac" another one I have is "preromanticism osteopathic" Hard, huh? Please send me something back.
  • where
    2004-06-09 08:05:21  nomis [Reply | View]

    whers the command line?

    #!/usr/local/bin/perl
    # google_whack.pl
    # An automated Google whacker.
    # Usage: perl google_whack.pl

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

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

    use strict;

    # Use the SOAP::Lite and LWP::Simple Perl modules
    use SOAP::Lite;
    use LWP::Simple;

    # Generate some random numbers to be used as dates for choosing
    # random word one.
    srand( );
    my $year = int( rand(2) ) + 2000;
    my $month = int( rand(12) ) + 1;
    $month < 10 and $month = "0$month";
    my $day = int( rand(28) ) +1;
    $day < 10 and $day = "0$day";

    # Pulling our first random word from Dictionary.com
    my $whackone =
    get("http://www.dictionary.com/wordoftheday/archive/$year/$month/$day.html")
    or die "Couldn't get whack word 1: $!";
    ($whackone) =
    ($whackone =~ /<TITLE>Dictionary.com\/Word of the Day: (.*)<\/TITLE>/i);

    # Generate a new year between 1997 and 2000 for choosing
    # random word two
    srand( );
    $year = int( rand(5) ) + 1997;

    # Pulling our second random word from th now defunct Maven's
    # Word of the Day (thank goodness for archives)
    my $whacktwo =
    get("http://www.randomhouse.com/wotd/index.pperl?date=$year$month$day")
    or die "Couldn't get whack word 2:: $!";
    ($whacktwo) = ($whacktwo =~ m!<h2>(.*)</h2>!i);

    # Build our query out of the two random words
    my $query = "$whackone $whacktwo";

    # Create a new SOAP::Lite instance, feeding it GoogleSearch.wsdl
    my $google_search = SOAP::Lite->service("file:$google_wdsl");

    # Query Google
    my $results = $google_search ->
    doGoogleSearch(
    $google_key, $query, 0, 10, "false", "", "false",
    "", "latin1", "latin1"
    );

    # A single result means a possible Google whack
    if ($results->{'estimatedTotalResultsCount'} == 1) {
    my $result = $results->{'resultElements'}->[0];
    print
    join "\n",
    "Probable Google whack for $query",
    "Title: " . $result->{title}||'no title',
    "URL: $result->{URL}",
    "Snippet: " . $result->{snippet}||'no title',
    "\n";
    }

    # Anything else is Google jack
    else {
    print "Google jack for $query, with " .
    $results->{'estimatedTotalResultsCount'} . " results\n";
    }
  • Check it:
    2004-05-31 21:51:53  What? [Reply | View]

    How fun it is to Whack a Whack

    ----solatium quoin----

    although I'm a little late on the game...
  • the fourth coming
    2004-03-12 04:14:36  tered [Reply | View]

    we bet you thought "yes ive defeated tered i am amazing" BUT NOOOOOOOOOOOO we have suceeded once again. dave you are the mud on our conjoined shoes (we are siamese twins)

    we will return shortly with more whackattacks

    but for now.............
    hatrick marsupial
  • !!!!!!!!!!!!!
    2004-03-12 03:49:16  dave69 [Reply | View]

    OOOOOOOOOOOOOOO!!! GET YOU CLEVER CLOGS!!!
    IM SO IMPRESSED...

    dave xxx
  • Hey look Tered!!
    2004-03-10 06:11:49  dave69 [Reply | View]

    Dont worry your not alone!
    I found a google whack today and thought of you:

    Sternpost platonism

    Enjoy.
  • It happened again...the second coming
    2004-02-25 04:21:05  tered [Reply | View]

    We said we'd back2whack and we are. Minutes after our first 2 triumphs we were astounded to find yet another whackage of the highest order. Yes brothers and sisters we found another and although you may doubt us, it too has one result and one result only...

    WUTHERING GYRATORY!!
    amen
  • Whackaday we're the best!!
    2004-02-25 04:12:27  tered [Reply | View]

    HAHAHAHAHAHAHAHAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAA!!!
    We found two in one sitting!HOORAH!!

    1. Sericulture endomorph
    2. Terraqueous autobus

    Need i say more...no i won't, except, we rule and u don't.
    Ciao for now, we'll be back2whack
    TERED
  • Found one!! HA
    2004-02-10 20:57:31  shaunf79 [Reply | View]

    Necro beastitly :) try it!!!
  • A GOOGle WHACK
    2004-01-25 00:07:37  xander123 [Reply | View]

    here is one i found its
    ballerina fishcake
  • ben is sexy and ive got 1
    2003-12-23 07:11:00  anonymous2 [Reply | View]

    try this - goggles physcology
  • Zak found a GOOGLE WHACK
    2003-12-23 02:22:27  anonymous2 [Reply | View]

    Try this one: sternocleidomastoid organometal
  • This is fun!
    2003-12-17 16:48:11  anonymous2 [Reply | View]

    Try:
    unimpuned racer
  • I found another one
    2003-12-11 17:51:06  anonymous2 [Reply | View]

    This one has both of the words in the Google list:

    "Hemispherical Decembrist" returns only one result.
  • I found one
    2003-12-11 17:46:50  anonymous2 [Reply | View]

    Although one of the words isn't in the google word list, it is in a few dictionaries:

    "pneumonoultramicroscopicsilicovolcanoconiosis lexicographical" returns only one result
  • < 5 mins
    2003-11-21 12:12:27  anonymous2 [Reply | View]

    what the hell is all the fuss about? It took less than 5 mins and a few words off the top of my head. Save your scriptings skills for something more worthwhile.

    Your search - nefarious confustication - did not match any documents.
  • jamming words together at random.
    2003-11-14 18:09:38  anonymous2 [Reply | View]

    indivisible lycanthropic
  • Synthetic Googlewhacks:
    2003-10-05 02:32:19  anonymous2 [Reply | View]

    To manufacture a Googlewhack, simply find two terms that give no results, and then post them here. Google spiders this page; you've created a Googlewhack.

    http://www.pyresite.da.ru
  • how to
    2003-08-29 18:24:08  anonymous2 [Reply | View]

    biogenetical conceptualization - did not match any documents
  • steven
    2003-08-19 18:53:50  anonymous2 [Reply | View]

    i have found yet another word with only 1 website frabilicious
    and codon4
  • how to run
    2003-08-18 07:39:52  anonymous2 [Reply | View]

    How do you run this script? Do you need a server to run it?
  • Better Whacking tips
    2003-07-08 07:11:48  anonymous2 [Reply | View]

    When using such phrases as "cataract pettifogger", words such as "my, but, new, can, and, because, erase" can, and will reduce search results. Even with this whack posted, I created a new one out of it.
  • soooo anoying
    2003-06-27 09:16:30  anonymous2 [Reply | View]

    im afraid i gave up after 10 min and tried to find the most results, 'the' gives the most
  • Only 1
    2003-04-29 16:45:58  anonymous2 [Reply | View]

    try this my pussycatman
  • get 2
    2003-04-29 16:42:18  anonymous2 [Reply | View]

    type my nalamina
  • One hit word
    2003-04-29 15:50:37  anonymous2 [Reply | View]

    If you type the word Poonstab into the google search engine, youll only get one page of over 2 billion.
    Luvnapkin@yahoo.com
  • flaw
    2003-04-18 08:23:28  anonymous2 [Reply | View]

    The code is flawed. Some of the words of the day are actually phrases. This means that some queries will be on more than two words.
    Also, online 44, there's a syntax error. Switch the 'm' and the '!'.
  • Scratch those whacks
    2003-04-10 00:12:29  anonymous2 [Reply | View]

    Note the examples of whacks you listed now make this article show up on Google, thus they are no longer whacks.
  • how to
    2003-04-09 17:15:40  anonymous2 [Reply | View]

    how would put that in to google? Yes i know i am a nOOb lol.

Showing messages 1 through 62 of 62.

O'Reilly Home | Privacy Policy

© 2007 O'Reilly Media, Inc.
Website: | Customer Service: | Book issues:

All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.