gpt4 book ai didi

javascript - imacros/javascript 循环,在下一个按钮上有条件

转载 作者:行者123 更新时间:2023-12-03 03:05:44 25 4
gpt4 key购买 nike

JavaScript 菜鸟,我尝试制作一个从 StackoverFlow 帖子中找到的脚本来在我的宏中工作,但它无法按应有的方式工作,

我想做的是:

1- 使用从 csv 文件中提取的关键字搜索 google,2-提取并保存内容。3-转到下一页结果,然后提取并保存,4-它应该继续下一个按钮,直到没有下一个按钮,5-然后它应该转到 csv 文件中的下一个关键字。

循环有效,但我不知道为什么它只单击“下一步”按钮 4 次,然后继续执行下一个关键字。

我在开始时尝试了两种带有“while”条件的变体,但结果是相同的。

感谢您对此的帮助,我在 Windows 7 32 位和 imacros 8.9.7 上使用 FF 55这是我的宏,不包括提取和保存,

                            var macro;
macro = "CODE:";
macro += "SET !ERRORIGNORE YES" + "\n";
macro += "SET !EXTRACT_TEST_POPUP NO" + "\n";
macro += "SET !DATASOURCE keywords.csv" + "\n";
macro += "SET !DATASOURCE_COLUMNS 1" + "\n";
macro += "SET !LOOP 1" + "\n";
macro += "SET !DATASOURCE_LINE {{RowNo}}" + "\n";

macro += "URL GOTO=https://www.google.com/ncr" + "\n";
macro += "TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT={{!COL1}}" + "\n";
macro += "TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:tsf ATTR=NAME:btnK" + "\n";

var NextBtnCheck=iimGetLastExtract();

var NextButton;
NextButton = "CODE:";
NextButton += "SET !ERRORIGNORE YES" + "\n";
NextButton += "SET !EXTRACT_TEST_POPUP NO" + "\n";
NextButton += "TAB T=1" + "\n";

NextButton += "WAIT SECONDS=1" + "\n";
NextButton += "TAG POS=1 TYPE=A ATTR=TXT:Next" + "\n";
NextButton += "WAIT SECONDS=0.5" + "\n";


for(var m=1; m<60; m++)
{iimSet("RowNo",m)
iimPlay(macro)

var n = 0
var n= iimPlay(NextButton);

do
{
iimSet("n",n)
iimPlay(NextButton);

if (NextBtnCheck !== "#EANF#");
break;
n++;
}
while(true)
{
iimSet("n",n);
iimPlay(NextButton);
}
}

最佳答案

我已经更正了您的代码,如下所示:

var macro =  "SET !DATASOURCE keywords.csv" + "\n";
macro += "SET !DATASOURCE_LINE {{RowNo}}" + "\n";
macro += "URL GOTO=https://www.google.com/ncr" + "\n";
macro += "TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT={{!COL1}}" + "\n";
macro += "TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:tsf ATTR=NAME:btnK" + "\n";

var NextButton = "TAB T=1" + "\n";
NextButton += "WAIT SECONDS=1" + "\n";
NextButton += "TAG POS=1 TYPE=A ATTR=TXT:Next" + "\n";
NextButton += "WAIT SECONDS=0.5" + "\n";

for(var m=1; m<60; m++) {
iimSet("RowNo",m)
iimPlayCode(macro)

do {
var NextBtnCheck = iimPlayCode(NextButton);
if (NextBtnCheck != 1)
break;
} while(true)
}

关于javascript - imacros/javascript 循环,在下一个按钮上有条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47177879/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com