Google Hacks Free Open Book

Google Hacks

Previous Section Next Section

Hack 87 Google Whacking

figs/beginner.giffigs/hack87.gif

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

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";
}

87.1 Running the Hack

Simply call the script on the command line with no arguments at all.

87.2 The Results

Here's a sample Google whack session. Told you it was hard!

% perl google_whack.pl Google jack for wan palooka, with 48 results
% perl google_whack.pl Google jack for hebetude Maisie, with 0 results
% perl google_whack.pl Google jack for lexicography doldrums, 
  with 90 results
% perl google_whack.pl Google jack for foundling hokey, 
  with 12 results
% perl google_whack.pl Google jack for cataract pettifogger, 
  with 6 results
... 
    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
    Chapter 7. Google Pranks and Games
    7.1 Hacks #86-92
    Hack 86 The No-Result Search (Prank)
    Hack 87 Google Whacking
    Hack 88 GooPoetry
    Hack 89 Creating Google Art
    Hack 90 Google Bounce
    Hack 91 Google Mirror
    Hack 92 Finding Recipes
    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