From: Mikkel Bruun Date: 2001-12-08T18:00:43+09:00 Subject: [ruby-talk:27908] Re: Dictionary.com speeder upper This is a multi-part message in MIME format. ------=_NextPart_000_0080_01C17FCF.5324C100 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable very nice!!! Mikkel ----- Original Message -----=20 From: Ralph Mason=20 To: ruby-talk ML=20 Sent: Saturday, December 08, 2001 6:10 AM Subject: [ruby-talk:27897] Dictionary.com speeder upper Here is a little script I did to make dictionary.com more useful for = me. =20 I think others may find it useful. Note: the HTML formatting it uses = sucks =20 Ralph =20 =20 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_0080_01C17FCF.5324C100 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable

very nice!!!
 
Mikkel
----- Original Message -----
From:=20
Ralph=20 Mason
To: ruby-talk=20 ML
Sent: Saturday, December 08, = 2001 6:10=20 AM
Subject: [ruby-talk:27897] = Dictionary.com=20 speeder upper

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=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 = -->/
  $' =3D~ /<!-- resultItemEnd=20 -->/
  a=3D$'
 
  puts  = $`.gsub(/<.*?>/m){=20 |i|
   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_0080_01C17FCF.5324C100--