Advertisement
Guest User

Untitled

a guest
May 2nd, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.87 KB | None | 0 0
  1. #!/usr/bin/perl -X
  2.  
  3. ##########
  4. $user = ''; # Enter your username here
  5. $pass = ''; # Enter your password here
  6. ###########
  7.  
  8. # Server settings (no need to modify)
  9. $home = "http://perltest.my-mobile.org";
  10. $url  = "$home/c/test.cgi?u=$user&p=$pass";
  11.  
  12. # Get HTML code
  13. $html = `GET "$url"`;
  14.  
  15. #### Add code here:
  16. # Grab img from HTML code
  17. my $img = "";
  18.  
  19. #########
  20. die "<img> not found\n" if (!$img);
  21.  
  22.  
  23. # Download img to server (save as: ocr_me.img)
  24. print "GET '$img' > ocr_me.img\n";
  25. system "GET '$img' > ocr_me.img";
  26.  
  27.  
  28. #### Add code here:
  29. # Run OCR (using shell command tesseract) on img and save text as ocr_result.txt
  30.  
  31. ###########
  32. die "ocr_result.txt not found\n" if (!-e "ocr_result.txt");
  33.  
  34. # Check OCR results:
  35. $txt = `cat ocr_result.txt`;
  36. $txt =~ s/[^A-Za-z0-9\-_\.]+//sg;
  37. $img =~ s/^.*\///;
  38. print `echo -n "file=$img&text=$txt" | POST "$url"`;
  39.  
  40. 1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement