Search Google Topics
Run queries against some of the available Google API specialty topics.
Google doesn’t talk about it much, but it does make specialty web searches available. And I’m not just talking about searches limited to a certain domain. I’m talking about searches that are devoted to a particular topic (http://www.google.com/options/specialsearches.html). The Google API makes four of these searches available: the U.S. Government, Linux, BSD, and Macintosh.
In this hack, we’ll look at a program that takes a query from a form and provides a count of that query in each specialty topic, as well as a count of results for each topic. This program runs via a form.
Why Topic Search?
Why would you want to topic search? Because Google currently indexes over eight billion pages. If you try to do more than very specific searches, you might find yourself with far too many results. If you narrow down your search by topic, you can get good results without having to exactly zero in on your search.
You can also use it to do some decidedly unscientific research. Which
topic contains more iterations of the phrase “open
source”? Which contains the most pages from
.edu
(educational) domains? Which topic,
Macintosh or FreeBSD, has more on user interfaces? Which topic holds
the most for Monty Python fans?
The Code
Save the following code as a CGI script ["How to Run
the Hacks” in the Preface] named
gootopic.cgi
in the cgi-bin
directory on your web server:
#!/usr/local/bin/perl # gootopic.cgi # Queries ...
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.