//获得下载图片的文件大小 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:\\test1.bat" ); //在CMD命令行中运行OCR命令 /* 在C盘根目录下创建批处理文件test1.bat: #进入到含有验证码图片的目录 c: cd\ #转换下载的JPG文件为TIF convert.exe -compress none -depth 8 -alpha offtest1.jpg test1.tif #调用tesseract转换图片中的文件并保存到test1.txt文件中 tesseract.exe test1.tif test1 #执行完成后,自动退出命令行 exit */ if((filedess = fopen("c:\\test1.txt","rt")) == NULL) { lr_output_message("oh,cloud your Open File Failed!"); return -1; } fread( result,4,1,filedess );//从文件中读取验证码 fclose( filedess ); lr_output_message("result: %s", result); //打印出读取后的数据 lr_save_var(result,MAX_NAME_LEN,0,"VC" ); //保存指定位数的数据到变量中 web_submit_data("UserAction", "Action=http://192.168.12.1:8080/action/UserAction", "Method=POST", "RecContentType=text/html", "Referer=http://192.168.12.1:8080/", "Snapshot=t2.inf", "Mode=HTML", ITEMDATA, "Name=method","Value=login", ENDITEM, "Name=goPage","Value=/index.html", ENDITEM, "Name=currentPage","Value=/", ENDITEM, "Name=username","Value=admin", ENDITEM, "Name=password","Value=123456", ENDITEM, "Name=ValidateCode","Value={VC}", ENDITEM, //输入获取的验证码 "Name=loginSubmit", "Value=登录", ENDITEM, EXTRARES, ... LAST); |