#!/usr/bin/ruby # # dic # Version 0.22 -- 2001.4.26, for eijiro_red # Version 0.30 -- 2002.2.25, for eijiro_red2 # Version 0.40 -- 2002.8.2, for eijiro_red2,GET,referer # Version 0.41 -- 2002.10.11 # # Copyright (C) Norio KATO 2000--2002 # # Permissions are granted to use, modify, and/or distribute this script. # Reporting to your distributer is appreciated # when you find circumstances have changed. # # usage: # [ruby] dic word or phrase | less require "socket" rhost_name = 'home.alc.co.jp' port = 80 file_path = '/db/owa/eijiro_red2' prefix = 'type_in=ej&word_in=' suffix = '' title = '[ALC English-Japanese Dictionary]' location = 'http://www.alc.co.jp/' if ARGV.size > 0 then key = ARGV.join("+") else print "usage: dic keyword\n" exit end ## print "#{title}\n" ## print "#{location}\n\n" key.gsub!(" ","+") data = "#{prefix}#{key}#{suffix}" data_length = data.length() s = TCPSocket.open(rhost_name, port) s.write("GET #{file_path}?#{data} HTTP/1.1\n") s.write("Host: #{rhost_name}\n") ## s.write("User-Agent:\n") s.write("Referer: http://www.alc.co.jp/sa_menu.html\n") s.write("\n") output = open("|nkf","w") while s.gets # chop # output.write("<#{$_}>\n") # print "<#{$_}>\n" if ($_ =~ /