#!/usr/local/bin/perl # para llamar el script: # trad.cgi?palabra=&fromto= use CGI; $doc = new CGI; print $doc->header; use LWP::UserAgent; $word = $doc->param('palabra'); $fromto = $doc->param('fromto') || 'ec'; $from = ($fromto eq 'ec') ? 'EUS' : 'CAS'; $fromLong = ($fromto eq 'ec') ? 'Euskera' : 'Castellano'; $in_table = 0; while () { if (/START_TABLE/) { $in_table=1; next; } elsif (/END_TABLE/) { $in_table=0; next; } if (/PUT_WORD_HERE/) { print "$word\n"; next; } if (/PUT_BODY_HERE/) { if ($word ne '') { &read_file; &analyse_page; } next; } if (/ $checked = ($1 eq $fromto) ? 'checked' : ''; s/IS_CHECKED/$checked/; } if ($in_table) { print if ($word ne ''); next; } print; } exit 0; ################################################################# sub analyse_page { foreach (@content) { if (0 && /font-style: italic/) { />(.*)/; $word_from = $1; print "

$word_from

\n"; print "\n"; next; } if (/No se ha encontrado la palabra/) { print ""; last; } if (/
    /) { $level1 = 1; next; } elsif (/<\/ul>/) { $level1 = 0; $ital = join(', ', ($gender, $type)); $ital = "$gender$type"; print "
\n"; $gender = ''; $type = ''; next; } elsif ($level1) { if (/(.*?)<\/em>/) { $gender = $1; } if (/(.*?)<\/font>/) { $type = $1; } if (/(.*?)<\/strong>/) { $trad = $1; } next; } if (/
/) { $bq++; next; } elsif (/<\/blockquote>/) { $bq--; if ($bq==1) { print "
"; print ""; print ""; print "\n"; } next; } elsif ($bq==2) { if (/(.*?)\. \//) { $cast = $1; } if (/(.*?)<\/strong>/) { $eusk = $1; } } } # print "
No se ha encontrado esta palabra
"; print "$trad" if ($trad); print "($ital)" if ($ital); print "
$cast$eusk
\n"; } ################################################################# sub read_file { $ua = new LWP::UserAgent; $ua->agent("OlivierAgent/0.1 ".$ua->agent); # $ua->timeout(30); $req = new HTTP::Request 'POST' => "http://www1.euskadi.net/cgi-bin_m33/DicioIe.exe"; $req->content_type('application/x-www-form-urlencoded'); $req->content("IdiomaEntrada=$from&Idioma=CAS&Txt_$fromLong=$word"); $req->header('Accept' => 'text/html'); $res = $ua->request($req); @content = split /\n/, $res->content; } __DATA__ Diccionario 3000
 

PUT_WORD_HERE

START_TABLE
PUT_BODY_HERE
Datos obtenido a partir de Hiztegia 3000



END_TABLE
Busca una palabra:

Castellano a Euskera
Euskera a Castellano

Datos obtenidos
a partir de
Hizategia 3000