Find the Largest Page
We all know about Feeling Lucky with Google. But how about Feeling Large?
Google sorts your search results by PageRank. Certainly makes sense. Sometimes, however, you may have a substantially different focus in mind and want things ordered in some other manner. Recency is one that comes to mind. Size is another.
In the same manner that Google’s “I’m Feeling Lucky” button redirects you to the search result with the highest PageRank, this hack sends you directly to the largest (in kilobytes).
Tip
This hack works rather nicely in combination with repetition [Hack #15] .
The Code
Save the following code as a CGI script ["How to Run
the Hacks” in the Preface] named
goolarge.cgi
in your web
server’s cgi-bin
directory. Be
sure to replace insert key here
with your
Google API key.
#!/usr/local/bin/perl
# goolarge.cgi
# A take-off on "I'm Feeling Lucky," redirects the browser to the largest
# (size in K) document found in the first n results. n is set by number
# of loops x 10 results per.
# goolarge.cgi is called as a CGI with form input
# Your Google API developer's key.
my $google_key='insert key here
'; # Location of the GoogleSearch WSDL file. my $google_wdsl = "./GoogleSearch.wsdl"; # Number of times to loop, retrieving 10 results at a time. my $loops = 10; use strict; use SOAP::Lite; use CGI qw/:standard/; # Display the query form. unless (param('query')) { print header( ), start_html("GooLarge"), h1("GooLarge"), start_form(-method=>'GET'), 'Query: ', textfield(-name=>'query'), ...
Get Google Hacks, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.