O'Reilly Hacks
oreilly.comO'Reilly NetworkSafari BookshelfConferences Sign In/My Account | View Cart   
Book List Learning Lab PDFs O'Reilly Gear Newsletters Press Room Jobs  



cligoogle: command line google written in tcl
cligoogle is a tcl script that can be configured to search google and return the results on the command line. it returns a list of links based on your search terms.

Contributed by:
jose nazario
[05/22/03 | Discuss (1) | Link to this hack]

cligoogle (command line interface google, available at http://monkey.org/~jose/software/cligoogle/) is a small tcl script i wrote to do google searches on the command line. the purpose of this is to have a simple, hacker friendly interface to google. i spend a lot of my time on the command line, so anything that can be done that way is more quickly performed on the command line.

cligoogle has a very simple interface:

usage: google.tcl term1 [term2 ...] [!?]
        choose ! if you feel lucky
        choose ? to go to google's results

in the barest form, it returns a list of results:

$ google jose nazario
1       http://www.monkey.org/~jose/
2       http://www.monkey.org/~jose/presentations/thesis-defense/
3       http://biocserver.bioc.cwru.edu/~jose/
4       http://www.jose.nazario.com/
5       http://www.crimelabs.net/docs/
6       http://bsdsearch.com/eao/phorum/list.php?f=5
7       http://bsdsearch.com/eao/phorum/list.php?f=5&r=1
8       http://www.memoriaviva.com/Desaparecidos/D-G/godoy-a3.htm
9       http://lists.insecure.org/nmap-hackers/2000/Apr-Jun/0100.html
10      http://www.maximumbsd.com/

chosing the "lucky" option (!) opens the browser to the first link. chosing the "view results" option (?) brings up a browser with the search results available in the browser.

cligoogle also supports a highly configurable (and persistently stored) set of options:

google.tcl -config  
        element is one of browser, number, lang, or proxy
        values can be:
           browser: netscape, konq, mozilla
           number: number of results to return
           lang: support for en, es, de, and fr

the defaults are to use netscape in english with 10 results (which happened to be my default setting when i wrote this). with various contributions, cligoogle has also grown to support mozilla on windows.

all of this is done via a two stage procss: URL construction followed by scraping the returned HTML. no google API (or keys) are used. cligoogle suffers many of the same fragility issues that other google scrapers do.

i have used cligoogle to construct large (1000 element) search result pools for large data analysis as well as just normal every day usage. cligoogle was built using Tcl 8.3 on UNIX and does not require any external libraries (such as tcllib) as it builds its own HTTP request.

cligoogle is available under a BSD style license. a Tk front end has been developed but not incorporated into the toolkit.

See also:

  • "setting preferences", google hacks hack #1.

  • "hacking google URLs", google hacks hack #9.

  • "scraping google results", google hacks hack #44.


O'Reilly Home | Privacy Policy

© 2007 O'Reilly Media, Inc.
Website: | Customer Service: | Book issues:

All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.