This is the spanish-english version. It's not currently
working because they just changed the user interface to
the site. Note that the only significant difference to my
webster client is that this one uses the POST protocol.
Feel free to contact me if you run into any problems.
#!/usr/bin/perl -w
use HTML::TreeBuilder;
use HTML::FormatText;
$|=1; # Asynchronous I/O.
use LWP::UserAgent;
my $ua = new LWP::UserAgent;
my $ua->agent("Diccionario");
#$ua->proxy([ 'http' ], 'http://www-dms.esd.sgi.com:8080/');
#
# Create a new request.
#
my $req = new HTTP::Request POST => "http://www.anaya.es/dicc/dicc/VOX
+ESPResult.html";
$req->content_type('application/x-www-form-urlencoded');
$req->content("TipoBusqueda=Emp&Entrada=$ARGV[0]&MaxFilas=10");
#
# Pass Request to the user agent and get a response back.
#
my $res = $ua->request($req);
#
# Print outcome of the response.
#
if(! $res->is_success) {
print "Failure to connect to server: " . $res->message;
} else {
$html = $res->content;
$p = HTML::TreeBuilder->new;
$p->parse($html);
$formatter = HTML::FormatText->new(leftmargin => 0, rightmargin => 6
+0);
$result = $formatter->format($p);
@parrafos = split /^\s+/m, $result;
for($x=1; !($parrafos[$x] =~ /^\[FORM/) and $x < 10; $x++) {
print $parrafos[$x]."\n" if !($parrafos[$x] =~ /^----/);
}
}
|