dictcc

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

dictcc

Unread post by machinebacon » Fri Mar 07, 2014 3:29 pm

by Christian Neukirchen, da great CWM guy ;)

Code: Select all

#!/usr/bin/env ruby
# dictcc WORD - simple dict.cc interface
require 'open-uri'
require 'cgi'

html = open("http://www.dict.cc/?s=#{CGI.escape ARGV.join(" ")}").read
c1, c2 = html.scan(/var c[12]Arr = new Array(.*?);/).map { |c|
  c[0].scan(/"(.*?)"/).flatten.map { |s| s.delete("\\") }
}
exit 1  unless c1 && c2
c1.zip(c2).each { |en, de| puts "#{en} :: #{de}"  unless en == "" || de == "" }
This is German<->English, but of course replace the country codes in the last line (there's a bunch!)
..gnutella..

Post Reply