我的英语不是很好,我希望能解释我能做的最好的事情
有没有办法根据提取的文本运行宏?
这段代码是测试,首先要做的是提取一个数字,如果数字匹配if (G_Extract!=="4")
则执行名为" run"如果没有,重定向到谷歌页面,问题是它执行所有代码而不重视if (G_Extract!=="4")
并忽略submit = "CODE:";
verify += "URL GOTO=http://www.google.com/" + "\n";
iimPlay(submit)}
for (i = 0; i < 50000; i++) {
var verify;
verify = "CODE:";
verify += "URL GOTO=https://www.random.org/" + "\n";
verify += "FRAME F=1" + "\n";
verify += "TAG POS=1 TYPE=INPUT:NUMBER ATTR=ID:true-random-integer-generator-max CONTENT=5" + "\n";
verify += "TAG POS=1 TYPE=INPUT:BUTTON ATTR=ID:true-random-integer-generator-button" + "\n";
verify += "TAG POS=1 TYPE=SPAN ATTR=ID:true-random-integer-generator-result EXTRACT=TXT" + "\n";
iimPlay(verify)
var G_Extract= iimGetLastExtract(1);
if (G_Extract!=="4")
{
var Run;
Run = "CODE:";
Run += "URL GOTO=http://demo.imacros.net/Automate/Extract2" + "\n";
Run += "TAG POS=1 TYPE=TD ATTR=CLASS:bdytxt&&TXT:* EXTRACT=TXT" + "\n";
Run += "TAG POS=1 TYPE=A ATTR=TXT:H*links* EXTRACT=TITLE " + "\n";
Run += "TAG POS=1 TYPE=SPAN ATTR=CLASS:bdytxt&&TXT:* EXTRACT=HTM " + "\n";
Run += "TAG POS=1 TYPE=A ATTR=TXT:HREF<SP>extracts<SP>links EXTRACT=HREF " + "\n";
Run += "TAG POS=1 TYPE=IMG ATTR=SRC:*shark_thumbnail.jpg EXTRACT=ALT " + "\n";
Run += "TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:form1 ATTR=NAME:abc EXTRACT=TXT " + "\n";
Run += "TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:form1 ATTR=ID:TF2 EXTRACT=TXT " + "\n";
Run += "TAG POS=2 TYPE=TABLE ATTR=TXT:*My* EXTRACT=TXT " + "\n";
Run += "TAG POS=1 TYPE=TD ATTR=CLASS:bdytxt&&TXT:* EXTRACT=TXT " + "\n";
Run += "TAG POS=1 TYPE=TH ATTR=TXT:MyTable" + "\n";
Run += "TAG POS=R3 TYPE=TD ATTR=TXT:* EXTRACT=TXT" + "\n";
iimPlay(Run)
}
else
{var submit;
submit = "CODE:";
verify += "URL GOTO=http://www.google.com/" + "\n";
iimPlay(submit)}
//New Step
iimPlay(verify)
var G_Extract= iimGetLastExtract(1);
if (G_Extract!=="4")
{
iimPlay(Run)
}
else
{iimPlay(submit)}
//New Step
iimPlay(verify);
var G_Extract= iimGetLastExtract(1);
if (G_Extract!=="4")
{
iimPlay(Run)
}
}
答案 0 :(得分:0)
我检查了你的代码,我发现代码有两个问题,你在submit
块中定义了变量else
,所以它只在else块内可用,第二个错误是,在网站random.org
中,当您点击生成按钮时,需要一些时间来生成值,我认为IMacros不会等待您当前代码中收到的值!为此,我建议添加WAIT SECONDS=3
,以便有足够的时间来加载随机数。请在下面找到我更正后的代码!
<强> iMacros的:强>
for (i = 0; i < 50000; i++) {
var verify;
verify = "CODE:";
verify += "URL GOTO=https://www.random.org/" + "\n";
verify += "FRAME F=1" + "\n";
verify += "TAG POS=1 TYPE=INPUT:NUMBER ATTR=ID:true-random-integer-generator-max CONTENT=5" + "\n";
verify += "TAG POS=1 TYPE=INPUT:BUTTON ATTR=ID:true-random-integer-generator-button" + "\n";
verify += "WAIT SECONDS=3" + "\n";
verify += "TAG POS=1 TYPE=SPAN ATTR=ID:true-random-integer-generator-result EXTRACT=TXT" + "\n";
iimPlay(verify)
var submit;
submit = "CODE:";
verify += "URL GOTO=http://www.google.com/" + "\n";
var G_Extract = iimGetLastExtract(1);
if (G_Extract !== "4") {
var Run;
Run = "CODE:";
Run += "URL GOTO=http://demo.imacros.net/Automate/Extract2" + "\n";
Run += "TAG POS=1 TYPE=TD ATTR=CLASS:bdytxt&&TXT:* EXTRACT=TXT" + "\n";
Run += "TAG POS=1 TYPE=A ATTR=TXT:H*links* EXTRACT=TITLE " + "\n";
Run += "TAG POS=1 TYPE=SPAN ATTR=CLASS:bdytxt&&TXT:* EXTRACT=HTM " + "\n";
Run += "TAG POS=1 TYPE=A ATTR=TXT:HREF<SP>extracts<SP>links EXTRACT=HREF " + "\n";
Run += "TAG POS=1 TYPE=IMG ATTR=SRC:*shark_thumbnail.jpg EXTRACT=ALT " + "\n";
Run += "TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:form1 ATTR=NAME:abc EXTRACT=TXT " + "\n";
Run += "TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:form1 ATTR=ID:TF2 EXTRACT=TXT " + "\n";
Run += "TAG POS=2 TYPE=TABLE ATTR=TXT:*My* EXTRACT=TXT " + "\n";
Run += "TAG POS=1 TYPE=TD ATTR=CLASS:bdytxt&&TXT:* EXTRACT=TXT " + "\n";
Run += "TAG POS=1 TYPE=TH ATTR=TXT:MyTable" + "\n";
Run += "TAG POS=R3 TYPE=TD ATTR=TXT:* EXTRACT=TXT" + "\n";
iimPlay(Run)
} else {
iimPlay(submit)
}
//New Step
iimPlay(verify)
var G_Extract = iimGetLastExtract(1);
if (G_Extract !== "4") {
iimPlay(Run)
} else {
iimPlay(submit)
}
//New Step
iimPlay(verify);
var G_Extract = iimGetLastExtract(1);
if (G_Extract !== "4") {
iimPlay(Run)
}
}