Perl使用Tesseract-OCR实现验证码识别教程

2019-10-01 11:37:42王振洲

    $i = $i + 1;
}
 
for (my $i=0; $i < @pxy; $i++) {     if( length(${$pxy[$i]}{ip})>0 )
    {
        `echo off & wget ${$pxy[$i]}{ip} -q -O ___png`;
        `tesseract ___png ___ -l chi_tra`;
 
        my $txt = undef;  
        open FH,"<___.txt";
        $txt = ;
        close FH;
        if ( length($txt)>11 )
        {
            $txt =~ s/s+//g;
            $txt =~ s/日/8/g;
            $txt =~ s/昍/88/g;
            $txt =~ s/s0/60/g;
            $txt =~ s/s1/61/g;
            $txt =~ s/s2/62/g;
            $txt =~ s/s3/69/g;
            $txt =~ s/s4/64/g;
            $txt =~ s/s5/65/g;
            $txt =~ s/s7/67/g;
            $txt =~ s/s8/68/g;
            $txt =~ s/s9/69/g;
            $txt =~ s/0s/06/g;
            $txt =~ s/1s/16/g;
            $txt =~ s/2s/26/g;
            $txt =~ s/3s/96/g;
            $txt =~ s/4s/46/g;
            $txt =~ s/5s/56/g;
            $txt =~ s/6s/66/g;
            $txt =~ s/7s/76/g;
            $txt =~ s/8s/86/g;
            $txt =~ s/9s/96/g;
            $txt =~ s/ss/66/g;
            $txt =~ s/.s/.6/g;
            ${$pxy[$i]}{ip} = $txt;