• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • 使用Tesseract-OCR在loadrunner中識別驗證碼

    發表于:2013-04-01來源:博客園作者:ZhuQue點擊數: 標簽:驗證碼
    使用Tesseract-OCR在loadrunner中識別驗證碼,知道還有一個Tesseract-OCR可以用來識別圖片上的文字(驗證碼)。

    有一個Tesseract-OCR可以用來識別圖片上的文字(驗證碼)。

      在code.google上下載了tesseract-ocr-setup-3.02.02.exe,即windows版本,下載安裝后安裝路徑自動加入到環境變量中,在cmd中可以手動測試一下:

      格式如下:tesseract.exe c:\test1.jpg c:\test -l

      //test1.jpg 是我提前保存在C盤中的驗證碼圖片,后面的test自動把test1.jpg中的驗證碼保存到test.txt中,后面-l是寫入到test.txt文件中的。

      按照云層提供的腳本,在system("c:\test.bat");無法運行,批處理腳本一閃就沒有啦。修改了system("c:\\test.bat");,并修改了批處理文件,加入了pause,提示錯誤。如下圖:

      loadrunner工具不識別tesseract.exe命令,但是手動在任何目錄中都是可以的,難道通過LR打開的終端窗口對windows中的path環境變量不識別??這個稍后嚴重。。

      看樣子只能修改這個批處理文件啦,把路徑指定到tesseract的安裝目錄中去才可以。

      然后運行成功,在自動生成的test.txt中可以看到獲取的驗證碼,也可以再LR的輸出中看到驗證碼:t4zbyh

      試了幾個驗證碼,大多沒有問題,

      其中下面的不能被識別(2013年3月8日補充:并不是所有HTTPS的不能被識別,中信銀行信用卡中心的驗證碼(純數字的)就可以被識別https://creditcard.ecitic.com/citiccard/cppnew/jsp/valicode.jsp?time=1362724476515,一些驗證碼不被識別的原因還待摸索,為什么https純數字的驗證碼就可以,難道其他的驗證碼是英文字符或者是加粗或者是圖片太大的原因嗎??):前面帶有HTTPS的,

      https://passport.csdn.net/ajax/verifyhandler.ashx?r_d=63178

      下面是loadrunner腳本:現在C盤中建立test.bat批處理

    復制代碼

      Action()

      {

      int flen; //定義一個整型變量保存獲得文件的大小

      long filedes; //保存文件句柄

      char file[256]="c:\\test1.jpg"; //保存文件路徑及文件名

      char result[10]; //存放驗證碼的

      web_set_max_html_param_len("2000000");//設置頁面接收最大的字節數,該設置應大于下載文件的大小

      web_reg_save_param("pic",

      "LB=",

      "RB=",

      "Ord=1",

      "Search=Body",

      LAST);

      web_url("randpiccloud","URL=https://passport.csdn.net/ajax/verifyhandler.ashx?r_d=63178",LAST);

      //http://biz.ftuan.com/CheckImg.aspx

      //http://passport.ftuan.com/SecurityCode.aspx?refresh=Wed Mar 6 11:21:21 UTC+0800 2013

      //http://comment8.mydrivers.com/radompage.aspx?0.{rnum}

      //https://passport.gaopeng.com/captcha?w=98&h=36&r=0.4655476964544505

      //https://passport.csdn.net/ajax/verifyhandler.ashx?r_d=63178

      flen = web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE); //獲得文件大小

      if(flen > 0)

      {

      if((filedes = fopen(file, "wb")) == NULL)

      {

      lr_output_message("oh cloud your Open File Failed!");

      return -1;

      }

      fwrite( lr_eval_string("{pic}"),flen,1,filedes );

      fclose( filedes );

      }

      system("c:\\test.bat");

      //調用C盤下的test.bat文件,改文件內容如下:

      /*

      c:

      cd C:\Program Files\Tesseract-OCR

      tesseract.exe c:\test1.jpg c:\test -l

      */

      //首先下載Tesseract工具并安裝,在批處理文件中必須cd到安裝目錄,否則LR調用時會提示“tesseract.exe不是內部命令”

      if((filedes = fopen("c:\\test.txt", "rt")) == NULL)

      {

      lr_output_message("oh,cloud your Open File Failed!");

      return -1;

      }

      fread( result,5,1,filedes); //此處控制驗證碼的長度

      fclose( filedes );

      lr_output_message("result: %s",result);

      lr_save_string(result,"txtCheck"); //傳驗證碼到txtCheck參數

      lr_output_message("txtCheck: %s",lr_eval_string("{txtCheck}")); //lr_eval_string("{txtCheck}")用在下面的登錄中

      return 0;

      }

    原文轉自:http://www.cnblogs.com/zhuque/archive/2013/03/06/2946565.html#2629177

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>