Category:
Author/Contact Info cider@compulsion.org || http://compulsion.org
Description: search - a quick and dirty hack to search google /fast/ using a text browser of your choice.
#!/usr/bin/perl

#
# search - a quick and dirty hack to search google /fast/ using a text
# browser of your choice.
# cider@compulsion.org
#

# choose one of these.
    $browser = "w3m";
    #$browser = "lynx -cookies";

$|++;    # unbuffered io hack
foreach $arg (@ARGV) { $string = $string . "+" . "$arg" } # parsing ha
+ck
$string =~ s/^\+//g; # hack to hack the parsing hack
print "searchstring is = $string\n"; # display the goods
sleep 1; # be lazy
system "$browser 'http://www.google.com/search?num=100&query=$string'"
+; # leave
  • Comment on search - a quick and dirty hack to search google fast using a text browser
  • Download Code
Replies are listed 'Best First'.
Re: search - a quick and dirty hack to search google fast using a text browser
by echo (Pilgrim) on Sep 27, 2001 at 12:08 UTC
    When building the query string it is not sufficient to join the arguments with '+'. An argument might contain an embedded space, or other characters not legal in a URI. The URI needs to be encoded according to RFC 2396. For this purpose you can use the URI::Escape module:

    use URI::Escape; $string = uri_escape(join(' ', @ARGV));
Re: search - a quick and dirty hack to search google fast using a text browser
by Chmrr (Vicar) on Sep 27, 2001 at 09:28 UTC

    If the purpose is to do it fast, why the sleep? Anyways, the following lines of your code:

    foreach $arg (@ARGV) { $string = $string . "+" . "$arg" } # parsing ha +ck $string =~ s/^\+//g; # hack to hack the parsing hack
    ..are better and more succintly put as merely $string = join '+', @ARGV

    perl -pe '"I lo*`+$^X$\"$]!$/"=~m%(.*)%s;$_=$1;y^+*`^ ve^#$&V"+@( NO CARRIER'