51Testing软件测试论坛
标题:
使用OCR来帮助LR实现认证码识别~遇到问题啦~求高手解答
[打印本页]
作者:
yangshuxin1989
时间:
2012-10-11 16:12
标题:
使用OCR来帮助LR实现认证码识别~遇到问题啦~求高手解答
本帖最后由 yangshuxin1989 于 2012-10-11 16:30 编辑
这几天在根据云老师的这篇文章在做验证码识别~然后想实践到自己工作的登录项目中,但是遇到一点问题呀~请各位高手指教一下。那个验证码是一个链接,我怎么知道每次请求的是什么呀~我直接把云层老师的代码插入到我的脚本中(当然,验证码的链接已经修改了),但是还是返回一个1006码,提示验证码错误。
Action()
{
int flen; //定义一个整型变量保存获得文件的大小
long filedes; //保存文件句柄
char file[256]="c:\\test1.jpg"; //保存文件路径及文件名
char result[4];
char res[4];
web_url("www.efunfun.com",
"URL=http://www.efunfun.com/",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t1.inf",
"Mode=HTML",
LAST);
web_url("login.do",
"URL=http://login.efunfun.com/login.do?method=js_isLogin&callback=rq.bd%5B1%5D=&ck=20121011161946664&rdm=0.4956840199491224",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=http://www.efunfun.com/",
"Snapshot=t2.inf",
"Mode=HTML",
LAST);
web_url("login.do_2",
"URL=http://login.efunfun.com/login.do?method=js_getUser&callback=rq.bd%5B2%5D=&ck=20121011161946664&rdm=0.22612070868305833",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=http://www.efunfun.com/",
"Snapshot=t3.inf",
"Mode=HTML",
LAST);
lr_think_time(6);
web_set_max_html_param_len("2000000");//设置页面接收最大的字节数,该设置应大于下载文件的大小
web_reg_save_param("pic",
"LB=",
"RB=",
"Ord=1",
"Search=Body",
LAST);
web_url("randpiccloud","URL=http://login.efunfun.com/verify_ck.jsp?ck={num1}&ram={num}",LAST);
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");;
if((filedes = fopen("c:\\test.txt", "rt")) == NULL)
{
lr_output_message("oh,cloud your Open File Failed!");
return -1;
}
fread( result,4,1,filedes);
fclose( filedes );
lr_output_message(result);
lr_save_var(result,4,0,"res");
//lr_output_message(res);
lr_output_message(lr_eval_string("{res}"));
lr_save_string(res,"a");
web_url("login.do_3",
"URL=http://login.efunfun.com/login.do?method=js_login&u=shuxin@qq.com&p=1qaz2wsx&c={a}&callback=rq.bd%5B4%5D=&ck=20121011161946664&rdm=0.2209274314358045",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=http://www.efunfun.com/",
"Snapshot=t4.inf",
"Mode=HTML",
LAST);
web_url("www.efunfun.com_2",
"URL=http://www.efunfun.com/?",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t5.inf",
"Mode=HTML",
LAST);
web_url("login.do_4",
"URL=http://login.efunfun.com/login.do?method=js_isLogin&SessionID=638ec38ee80c524d789c103a3b29984f&userid=-1&callback=rq.bd%5B1%5D=&ck=20121011162003623&rdm=0.08463324298331681",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=http://www.efunfun.com/?",
"Snapshot=t6.inf",
"Mode=HTML",
LAST);
web_url("login.do_5",
"URL=http://login.efunfun.com/login.do?method=js_getUser&SessionID=638ec38ee80c524d789c103a3b29984f&userid=-1&callback=rq.bd%5B2%5D=&ck=20121011162003623&rdm=0.1782930045923139",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=http://www.efunfun.com/?",
"Snapshot=t7.inf",
"Mode=HTML",
LAST);
return 0;
}
复制代码
作者:
yangshuxin1989
时间:
2012-10-11 16:59
求云层老师解答呀~
作者:
云层
时间:
2012-10-11 18:11
哎。本来就说过这种识别很难准的。。
作者:
yangshuxin1989
时间:
2012-10-11 19:26
回复
3#
云层
云老師,我也買了你的書,準備看了~
對於上面那個問題,要怎麼處理呀~老師
作者:
marsmaya
时间:
2012-10-16 14:31
我也试着做了下,但是c盘只有test1.jpg,图像打开是空白的
system("c:\\test.bat");; 这句是什么意思呢?
作者:
yangshuxin1989
时间:
2012-10-19 11:53
回复
5#
marsmaya
這句是批处理文件文件,你在C盤的地方新建一個txt文檔,然後輸入“tesseract.exe c:\test1.jpg c:\test -1”,另存為test.bat就可以了。
作者:
yangshuxin1989
时间:
2012-10-19 11:56
回复
5#
marsmaya
前提是你要裝了tesseract.exe
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/)
Powered by Discuz! X3.2