Gleaning Phonebook Stats
The Google API doesn’t return data from a search using the phonebook syntaxes, but that doesn’t mean you can’t have some fun with it.
The Google API doesn’t return results for queries
using the phonebook:
[Hack #17] syntaxes. It does, however,
provide a result count!
Because it doesn’t actually get you any phone numbers, passing a phonebook query to the Google API has minimal value. Nevertheless, this little hack makes the most of it. Ever wonder how many people with a particular surname one might find in various U.S. cities—the 15 most populated, at least?
The Code
#!/usr/local/bin/perl # kincount.cgi # How many people share a surname in the 15 most populated # US cities? # kincount.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"; # 15 most populated US cities my @cities = ("New York NY", "Los Angeles CA", "Chicago IL", "Houston TX", "Philadelphia PA", "Phoenix AZ", "San Diego CA", "Dallas TX", "San Antonio TX", "Detroit MI", "San Jose CA", "Indianapolis IN", "San Francisco CA", "Jacksonville FL", "Columbus OH"); use strict; use SOAP::Lite; use CGI qw/:standard *table/; print header( ), start_html("KinCount"), h1("KinCount"), start_form(-method=>'GET'), 'Surname: ', textfield(-name=>'query', -default=>'John Doe'), ' ', submit(-name=>'submit', -value=>'Search'), end_form( ), p( ); my $google_search = SOAP::Lite->service("file:$google_wdsl"); ...
Get Google Hacks 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.