Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

search - a quick and dirty hack to search google fast using a text browser

by cider (Acolyte)
on Sep 26, 2001 at 22:58 UTC ( [id://114907]=sourcecode: print w/replies, xml ) Need Help??
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'

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: sourcecode [id://114907]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-04-24 07:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found