| Hack: | Google Whacking | |
| Subject: | where | |
| Date: | 2004-06-09 08:05:21 | |
| From: | nomis | |
|
whers the command line?
|
||
Showing messages 1 through 2 of 2.
-
where
2004-12-28 09:00:03 AHCgooglewhack [View]
Command line?
-
where
2004-06-09 08:13:14 nomis [View]
#!/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";
}
| Showing messages 1 through 2 of 2. |


