I'm sure more experienced Ruby users can respond to the question of how
to do it in Ruby.  If that's  the kind of thing you are interested in
doing, you may be interested in the surfraw tool, which was written to
facilitate extracting URL's from search engines:

   http://surfraw.sourceforge.net/

If it doesn't completely fill your needs, you may be able to put together
a colloaboration between the two -- for example, running surfraw from
Ruby, and putting its output in a Ruby string :

  s = `surfraw ...`, then massaging the string using Ruby's extensive
string methods.  FWIW, YMMV.

Dennis

On Sun, 19 May 2002, Charles Blackburn wrote:

> Hi all.
> 
> just a quick and simple question.
> 
> I want to create a short script in ruby to do a simple google search and return the 1st x urls.
> 
> I have done it in bash scripting as i've shown here:
> 
> !/bin/sh
> if [ "$1" = "" ]; then
> 	echo "Usage: google <keyword 1> <keyword 2> <keyword 3> etc.."
> else
> 	lynx -dump "http://www.google.com/search?q=$2+$3+$4+$5+$6" | grep \/ | head -n"$1"|awk '{print $1}'
> fi
> 
> basically I need a ruby equivalent of that. can anyone help??
> 
> regards
> Charles
>