Hack 85 Searching the Internet from Your Desktop

figs/beginner.giffigs/hack85.gif

Thanks to a collection of freeware and shareware apps and a few clever hacks, you can weave Internet search into the fabric of your Mac computing experience.

Searching the Web with Google in particular has become such a part of our daily online lives that Google is now regarded as a verb and even the uber-literary New Yorker gets webby with Google-related cartoons. You're being Googled while on the phone with someone who can't quite remember who you are or why they asked you to ring them. Without Google close at hand, you're a day late and a dollar short.

Too bad web searching's so closely tied to the browser. For that matter, even choice of search engine is most often hardcoded into the browser and can't be pried loose without a modicum of hackery. Wouldn't it do wonders to be able to search from any application for the highlighted text right under your mouse pointer?

Thanks to a collection of freeware and shareware apps and a few clever hacks, all this and more is within reach. All of these solutions construct an appropriate query URL, much as you'd see in your browser's address bar after submitting a search directly (e.g., http://www.google.com/search?q=hacks).

85.1 Searchling

Michael Thole's Searchling (http://web.ics.purdue.edu/~mthole/searchling/) (open source donateware) embeds search functionality right into your menu bar for access from anywhere at any time (see Figure 8-1). Click the G that's G as in Google menu bar icon, type or paste your query in the fade-in search box, select your search engine of choice, and Searchling will bring up the results in your default web browser.

Figure 8-1. Searchling
figs/xh_0801.gif

Searchling ships with support for Google, Dictionary.com, and eBay. Beyond each engine's default search, a pull-down menu lets you home in on the type of search you're after. Search Google for web sites, images, or news; search Dictionary.com for a definition; or consult the thesaurus.

As one might hope, you're not limited only to the engines or types of searches Searchling offers out of the box. You can alter the offerings by editing Searchling's only mildly hairy sites.xml file. Perl maven Matt Sergeant added quick access to the vast array of Perl modules on the Comprehensive Perl Archive Network (CPAN), searchable by all, modules, distributions, and authors; his sites.xml is available at http://www.sergeant.org/searchling_sites.xml. Figure 8-2 shows a screenshot of it in action, along with the results presented in my browser. Note the generated URL in the address bar and appropriate search data in the web page itself.

Figure 8-2. Searchling searching CPAN
figs/xh_0802.gif

Google Groups (http://groups.google.com/) sports a comprehesive archive of the past 20 years of Usenet news. Let's add it to Searchling's list of supported Google search types. Find Searchling on your drive (probably Applications Searchling), Control-click its icon, and select Show Package Contents. Navigate down to to the Contents/Resources folder and open the sites.xml file in your favorite text editor. Add the wodge of XML called out in bold just below the piece defining the Google News search type:

... <dict> <key>type</key> <string>News</string> <key>url</key> <string>http://news.google.com/news?hl=en&q=</string> </dict> <dict> <key>type</key> <string>groups</string> <key>url</key> <string>http://groups.google.com/groups?hl=en&amp;q=</string> </dict> </array> ...

Notice how you need to escape & as &amp; in the search URL so that it sits well with the XML.

Alternately, if you prefer a more visual editing tool and have the Mac OS X Developer Tools [Hack #48] installed, open Searchling/Contents/Resources/sites.xml in Property List Editor (Developer Applications Property List Editor).

Save sites.xml, quit (Control-click the icon and select Quit Searchling) and relaunch Searchling. "groups" should now appear as a choice under Google Search Types.

Adding an entire site, as Matt did for CPAN and I for Meerkat: an Open Wire Service (http://www.raelity.org/archives/2002/12/04#computers/internet/www/search_engines/searchling), is just as simple. Copy an existing site definition, paste it alongside its peers, and make the appropriate edits. Any valid query URL will do; just be sure the last variable= is the one to accept query keywords (e.g., q= for Google, query= for CPAN, and s= for Meerkat).

85.2 Huevos

Huevos provides multiple-search-engine support it ships with 13 but is a little more obtrusive, floating about in a minimizeable window rather than tucking itself into the menu bar.

Huevos's major boon is the considerable ease with which you can add search engines to its stable. Select Huevos Preferences, click New, edit the Name and URL and your search engine of choice appears in the alphabetical list, as shown in Figure 8-3. No need for XML editing or even restarting the application; changes take effect immediately.

Figure 8-3. Huevos
figs/xh_0803.gif

Have Searchling or Huevos available to you from the moment you log in by dragging its Finder icon into the System Preferences Login Items Preferences pane.

85.3 SearchGoogle.service

SearchGoogle.service (http://gu.st/proj/SearchGoogle/) (public domain donateware) adds "search Google" functionality to just about any OS X application's (Finder included) Services menu. Highlight a snippet of text and select Services Search Google or press Shift-figs/command.gif-G to send the results to your default browser.

Installation is simple. Download the package, unstuff it, and drag SearchGoogle.service to ~/Library/Services (create this folder if it doesn't already exist). Log out and back in and Search Google should appear in your Services menu.

I found SearchGoogle.service to function adequately, working from the Finder, iChat, Terminal, and various other applications. The service was grayed out in the two applications in which I would have most expected it to work: the Internet Explorer and Mozilla-based browsers. At times, the keystroke combo didn't work, cured seemingly by manually selecting the service for first-time use in the current application.

SearchGoogle.service, while supporting only Google search, does afford you the ability to change the default search engine. Edit its SearchGoogle.service/Contents/Info.plist with Property List Editor or a text editor, altering the URL in SgDefaultURL. The same rules as Searchling apply: the keywords are appended to the end. To change the key binding, alter the value of NSServices > NSKeyEquivalent. In both cases, you'll need to log out and back in again for changes to take effect.

85.4 Watson

Watson (http://www.karelia.com/watson/) ($29 single user, $39 household, $15-per-seat site license, 10-100; free trial), by Karelia Software, is a snazzy front end to a plethora of XML-based and HTML-scraped web services. Highlights include Amazon.com, movies, VersionTracker (http://www.versiontracker.com/), recipes, stocks, translation, a Google tool (http://www.karelia.com/watson/plugins/google.html), and a wonderful columnar interface for browsing Yahoo! (http://www.karelia.com/watson/plugins/yahoo.html).

Thanks to a comprehensive developers' kit (http://www.karelia.com/developer/watson/), new tools for Watson are popping up frequently.

85.5 Sherlock

Then, of course, there's Sherlock 3 (http://www.apple.com/macosx/jaguar/sherlock.html) (bundled with every Mac OS X 10.2 Jaguar installation). Sherlock, remarkably similar to Watson, provides a clean front end to various web services, including Internet search (shown in Figure 8-4). While the default lineup of underlying web search engines (About.com, Ask Jeeves, Looksmart, etc.) don't top the favorites charts of anyone I know, Apple has released a Sherlock 3 Channel SDK (http://developer.apple.com/macosx/sherlock/), everything a developer might need to build additional Sherlock channels. It took only a short while for a Google search plug-in for Sherlock to put in an appearance.

Figure 8-4. Sherlock Internet search
figs/xh_0804.gif

Everything required to develop a channel is provided in the Sherlock Channel SDK, including technical documentation, a sample channel, a Project Builder template, and an Interface Builder Sherlock palette.

85.6 Hacking Your Browser

Then again, perhaps the browser is the most appropriate place for a web search. That doesn't mean you have to type http://www.google.com/ and fill out the form each time. There are various hacks available for building in support for Google and other search engine searches right from the address bar.

By far, the most elegant is Mozilla's keyword searching (http://www.mozilla.org/docs/end-user/keywords.html). Simply bookmark a search-result URL, use %s as a stand-in for the keywords, and associate a keyword (I use g) with it. To search, type the keyword you specified, followed by an appropriate query (e.g., g mozilla keywords) into the address field and press Return for results. Create as many of these keyword searches as you like: a for Amazon.com, m for meerkat, and so forth (see Figure 8-5).

Figure 8-5. Mozilla bookmark with keyword
figs/xh_0805.gif

Google maintains a Googlify your Browser page (http://www.google.com/options/defaults.html) with resources for making Google your default search engine and embedding search beyond the default Search button. For altering Internet Explorer's default search engine (triggered by typing ?, followed by keywords into the address bar), see http://www.macslash.com/articles/01/10/10/1828238.shtml and http://www.macntalk.com/tips/googleie.html.

85.7 How Lazy Can You Get?

True, it doesn't take much to launch your browser and browse to your favorite search-engine site. True, search results are usually returned in the browser anyway. But why take that one extra step and smidgen of mindwidth when you can click a menu bar icon, press Shift-figs/command.gif-G, or the like. It's all about integrating search into the fabric of your computing experience.



Mac OS X Hacks
Mac OS X Hacks: 100 Industrial-Strength Tips & Tricks
ISBN: 0596004605
EAN: 2147483647
Year: 2006
Pages: 161

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net