Exciteに再翻訳のチェックボックスがあったので、それを利用したプログラムを作ってみた
#! /usr/bin/ruby -Ku require 'net/http' require 'kconv' class Excite T_START = "<textarea cols=36 rows=15 name=\"reverse\" wrap=\"virtual\" style=\"width:320px;height:270px;\" onselect=\"insertDictionaryKeyword(this);\">"; T_END = "</textarea>"; def Excite.retranslate(text) submit = "before=#{text}&wb_lp=JAEN&reverse_option=yes".tosjis http = Net::HTTP.start('www.excite.co.jp') response = http.post('/world/english/', submit) body = response.body.toutf8 tstart = body.index(T_START) + T_START.length tend = body.index(T_END, tstart) - 1 return body.slice(tstart..tend) end end puts Excite.retranslate('炒飯作るよ!')