在条件|中循环iMacro如果不正确重复,解决验证码

时间:2016-12-12 05:01:21

标签: javascript loops captcha imacros

我正在尝试解决验证码并继续执行剩下的任务,但问题是如果我得到了错误的答案我可以回馈反馈,如果它是对的,但不能再次解决验证码离开,如果错误的上限,页面不会前进,它最终会在分配的时间和超时之后重新开始,但我想再次循环验证验证码区域的部分。我的代码工作正常,如果验证码答案是正确的,即使这几天是代码

SET apikey G9W API KEY GO HERE
SET !VAR1 NULL
SET !VAR2 NULL
SET !VAR3 NULL
SET !VAR4 NULL

'Step 1: Open WEBSITE
SET !ERRORIGNORE YES
URL GOTO=URL TO GO
WAIT SECONDS=10

URL GOTO=javascript:window.scrollBy(0,450)

'Step 2: Save Captcha ScreenShot
FILEDELETE NAME=d:\test.jpg
'SET !ERRORIGNORE NO
ONDOWNLOAD FOLDER=d:\ FILE=test.jpg
WAIT SECONDS=10
TAG POS=1 TYPE=DIV ATTR=ID:adcopy-puzzle-image CONTENT=EVENT:SAVE_ELEMENT_SCREENSHOT
WAIT SECONDS=5

'Step 3: Send Captcha For Solving to 9kw
TAB OPEN
TAB T=2
URL GOTO=http://www.9kw.eu/grafik/form.html
TAG POS=1 TYPE=INPUT ATTR=NAME:apikey CONTENT={{apikey}}
TAG POS=1 TYPE=INPUT ATTR=NAME:prio CONTENT=0
TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ACTION:/index.cgi ATTR=NAME:selfsolve CONTENT=NO
TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ACTION:/index.cgi ATTR=NAME:confirm CONTENT=NO
TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ACTION:/index.cgi ATTR=NAME:case-sensitive CONTENT=NO
TAG POS=1 TYPE=INPUT ATTR=NAME:source CONTENT=imacros
TAG POS=1 TYPE=INPUT ATTR=NAME:file-upload-01 CONTENT=d:\test.jpg
TAG POS=1 TYPE=INPUT ATTR=TYPE:submit
SET !EXTRACT_TEST_POPUP NO
SET !TIMEOUT_STEP 180
TAG POS=1 TYPE=INPUT ATTR=NAME:captchaid EXTRACT=TXT
SET !VAR1 {{!EXTRACT}}
'Clean the !EXTRACT variable for the next task
SET !EXTRACT NULL
'Extract the characters that are recoginzed from the picture of captcha.
TAG POS=1 TYPE=INPUT ATTR=NAME:result EXTRACT=TXT
WAIT SECONDS=1
TAB CLOSE

'Step 4: Check the captcha answer (text or nothing like #EANF# = Extraction Anchor Not Found)
SET !VAR2 EVAL("if (\"{{!EXTRACT}}\" == \"#EANF#\") {var x = \"\";} else {var x = \"{{!EXTRACT}}\";} x;")
'Clean the !EXTRACT variable for the next task
SET !EXTRACT NULL

'Step 5: Fill the recognized characters to the verification box
TAB T=1
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:adcopy_response CONTENT={{!VAR2}}
SET !TIMEOUT_STEP 40
WAIT SECONDS=5
SET !ERRORIGNORE YES
TAG POS=1 TYPE=INPUT:SUBMIT ATTR=ID:subbmit
WAIT SECONDS=5

'Step 6: Check and send the captcha feedback back to the captcha service (OK:1, NotOK:2, EN: Right/False, DE: Richtig/Falsch)
SET !EXTRACT NULL
SET !TIMEOUT_STEP 10
TAG POS=1 TYPE=P ATTR=TXT:Wrong<SP>Captchas EXTRACT=TXT
SET !VAR3 EVAL("if (\"{{!EXTRACT}}\" == \"#EANF#\") {var x = \"1\";} else {var x = \"2\";} x;")
TAB OPEN
TAB T=2
SET !TIMEOUT_STEP 60
URL GOTO=http://www.9kw.eu/index.cgi?source=imacros&action=usercaptchacorrectback&apikey={{apikey}}&correct={{!VAR3}}&id={{!VAR1}}
WAIT SECONDS=2
TAB CLOSE
TAB T=1
SET !VAR4 {{!VAR3}}

'Step 7 NEXT Tasks

我希望将代码从第2步循环到第6步,如果!VAR3的值为2表示验证码不正常但是如果它为1则表示验证验证码是正确的,我试图首先将宏拆分为3个宏一个包含步骤1第二个包含步骤2到6,第三个包含步骤7及以后并尝试在js脚本中调用它们如下

//Step 1 Open Website
iimPlay("test1.iim");

//STEP 2 to 6 Fill Captcha untill right

for(i=2;i<=1;i--)
{
iimSet("{{!VAR4}}",i);
iimPlay("test2.iim");
}

//STEP 7 Go About doing your thing
iimPlay("test3.iim");

但这通常是测试1跳过测试2和测试第3部分我尝试将所有代码放在js文件中并尝试相同的东西第二部分也跳过,我想要值!VAR3或控制循环并重复直到它有价值1

请帮我循环这第二部分我知道我不能在iim文件中这样做将不得不使用java而我不知道编程通常在DOS中我可以标记东西并且只是指向GOTO LABEL等但是这里我不知道该怎么做

1 个答案:

答案 0 :(得分:0)

您可以将iimGetLastExtract()用于iimPlay的返回值。 见http://wiki.imacros.net/iimGetLastExtract()