Bulgarian-English command line tool (using sa.dir.bg)
Posted by root Sat, 19 Jul 2008 21:59:00 GMT
#!/usr/bin/env ruby
require 'tempfile'
require 'net/http'
arg = ARGV[0].chomp
url = 'sa.dir.bg'
h = Net::HTTP.new(url, 80)
resp,data = h.get("/cgi/sabig.cgi?word=#{arg}", nil )
outtmp = Tempfile.new("translator")
outtmp << data.to_s
outtmp.rewind
puts %x[html2text "#{outtmp.path}"]
__END__