Googling

pudge on 2002-04-19T14:29:49

I took the demo Google API script and modified it to work to my needs. First, I made it pop up a dialog asking for search terms using MacPerl::Ask(). I reorganized it slightly, and added simple XML escaping (so I could search for "A&E"). Then I made a Template to output an HTML file, and used Mac::InternetConfig::GetURL() to open the file in my browser.

The result is this. A web page that looks how I want it to look. And since I can execute the script from any program with cmd-opt-shift-] (using OSAMenu), it is very convenient.

Sure, I could just have the script do GetURL("http://www.google.com/search?query=$searchterms"), but where is the fun in that? Plus, I could extend this to do a more elaborate dialog box, which would include a list of available search engines (using WWW::Search, perhaps), and a Google-like option to merely open the first returned site directly.

NOTE: MacPerl has a bug or two in it that prevents installing Template through normal means. Will be fixed in next release (necessary patches for MacPerl and for Template have been submitted).