#!/usr/bin/perl ######################################## # This script reads a google search appliance log file and displays the search terms # that returned 0 results. The strings displayed are *exactly* how the user entered # them as their search query. # # This script can be combined with the "grablogfile.pl" (www.blakecrosby.com/scripts.html) # script to download the log file that this perl script parses. # # # Questions about this script can be directed to: # Blake Crosby (bcrosby@nm.cbc.ca) # # The Canadian Broadcasting Corporation does not support nor endorse this script. # # # # This script was tested on FreeBSD. # This script was tested on a 1001 model Google Search Appliance # ######################################### ################################# # Config section # # # log file filename # For example: google.log $logfile = "google.log"; # # output file name # For example: zeroresults.txt $resultfile = "zeroresults.txt"; #### END OF CONFIG # # #Dont edit below this line, unless you know what you are doing. # open(LOGFILE,$logfile); while (){ $line = $_; @result = split / /,$line; $result[6] =~ /&ip=(.*)&/; $ip = $1; if ($result[10] eq "0") { $result[6] =~ /q=(.*)&site/; $stupidreadonly = $1; $stupidreadonly =~ s/\%([0-9A-F]{2})/pack('H*',$1)/ges; $stupidreadonly =~ s/\+/ /g; $finalresult{$stupidreadonly} = 1; } } open (REPORTFILE,">$resultfile"); print REPORTFILE join("\n", sort (keys(%finalresult))); close (REPORTFILE);