igor@30: #!/usr/bin/perl igor@30: igor@30: # written by Andrii Grytsenko, 2010 igor@30: igor@30: use Locale::Recode; igor@30: use LWP::UserAgent; igor@30: use strict; igor@30: igor@30: igor@30: sub parse_html { igor@30: my $text = shift; igor@30: my $result ; igor@30: $text =~ s/>\n]+>//g ; #delete all html tags igor@30: print "$line\n"; igor@30: } igor@30: } igor@30: igor@30: igor@30: my $cd = Locale::Recode->new (from => 'UTF-8', to => 'koi8-r'); igor@30: die $cd->getError if $cd->getError; igor@30: my $ua = LWP::UserAgent->new; igor@30: $ua->agent("Firefox/0.1 "); igor@30: igor@30: my $word = $ARGV[0]; igor@30: my $req = HTTP::Request->new(GET => "http://lingvo.abbyyonline.com/en/en-ru/$word"); igor@30: igor@30: my $res = $ua->request($req); igor@30: igor@30: if ($res->is_success) { igor@30: my $text = $res->content; igor@30: $cd->recode($text); # change code encoding from UTF-8 to koi8-ru igor@30: print "Translate for word $word\n"; igor@30: $text = parse_html($text); igor@30: print_html($text); igor@30: } else { igor@30: print $res->status_line, "\n"; igor@30: }