From: Ralph Mason Date: 2001-12-08T14:10:57+09:00 Subject: [ruby-talk:27897] Dictionary.com speeder upper This is a multi-part message in MIME format. ------=_NextPart_000_050E_01C18013.C6007FE0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Here is a little script I did to make dictionary.com more useful for me. I think others may find it useful. Note: the HTML formatting it uses = sucks Ralph require "net/http" if ARGV.size =3D=3D 0=20 puts "Usage: dictionary term" exit end a =3D = Net::HTTP.get("www.dictionary.com","/cgi-bin/dict.pl?term=3D#{ARGV[0]}") if ( a=3D~/No entry found for/ )=20 puts "No entry found for '#{ARGV[0]}' - Suggestions:\n\n" =20 while $' =3D~/(\w+)/ puts $1 end else while a =3D~ // $' =3D~ // a=3D$' puts $`.gsub(/<.*?>/m){ |i|=20 case i when "" "" when "" "\n" when "

" "" else "" end } end end ------=_NextPart_000_050E_01C18013.C6007FE0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable

Here is a little script I did to make=20 dictionary.com more useful for me.
 
I think others may find it useful. = Note: the HTML=20 formatting it uses sucks
 
Ralph
 
 
require "net/http"
 
if  ARGV.size =3D=3D 0 =
 puts =20 "Usage: dictionary term"
 exit
end
 
a =3D Net::HTTP.get("www= .dictionary.com","/cgi-bin/dict.pl?term=3D#{ARGV[0]}")
 
if ( a=3D~/No entry found for/ ) =
 puts "No=20 entry found for '#{ARGV[0]}' - = Suggestions:\n\n"
 
 while $'=20 =3D~/<a = href=3D"\/cgi-bin\/dict.pl\?term=3D\w+">(\w+)/
  puts=20 $1
 end
else
 while a =3D~ /<!-- resultItemStart=20 -->/
  $' =3D~ /<!-- resultItemEnd=20 -->/
  a=3D$'
 
  puts  = $`.gsub(/<.*?>/m){ |i|=20
   case i
    when=20 "<b>"
     ""
   &nbs= p;when=20 "</b>"
     "\n"
   &= nbsp;when=20 "<p>"
     ""
   &nbs= p;else
     ""
   end
&n= bsp;  }
 end
end
------=_NextPart_000_050E_01C18013.C6007FE0--