我有一个csv文件,包含128个不同的关键字(1列,128行),我试图在当前页面上搜索,如果找到其中一个继续执行非常简单的任务,则提示我说没有找到关键字。
目标是拥有以下内容:
SET !DATASOURCE ... 'already have this part working
SET !DATASOURCE_COLUMNS 1
SET !DATASOURCE_LINE {{!LOOP}}
{{!LOOP}} = 1
if TAG POS=1 TYPE=* ATTR=TXT:{{!COL1}} = true 'not actual code from here down
move to next step
elseif {{!LOOP}} +1 = 129
PROMPT "No keyword was found"
END 'killing the script
else
loop++ 'loop and search for next keyword
如果重要,关键字实际上是IP地址,最后一个块缺少IE。 #&34; 192.168.0&#34。不确定它是否会影响格式化。我确信通过搜索可以做到更好。如果关键字存在,我只是寻找0或1(是或否响应),然后如果找到则继续关注链接。
答案 0 :(得分:0)
如果你想做if等条件,你需要使用脚本语言[1]。我在下面提供了一个跟随你的伪代码的Javascript示例。
var datasource, macro, retcode, numberOfLinesInDatasource, aTagWasFound;
datasource = "somedatasource";
numberOfLinesInDatasource = 128;
aTagWasFound = false;
macro = "CODE:";
// change link to a different website
macro += "URL GOTO=http://stackoverflow.com/questions/25467549/trying-to-do-a-looped-search-for-keywords-with-imacros\n";
retcode = iimPlay(macro);
// loop through all lines in datasource
for (var i = 0; i < numberOfLinesInDatasource; i++)
{
// get the datasource value at this line
macro = "CODE:";
macro += "SET DATASOURCE " + datasource + "\n";
macro += "SET DATASOURCE_COLUMNS 1\n";
macro += "SET DATASOURCE_LINE " + i + "\n";
macro += "ADD !EXTRACT {{!COL1}}\n";
retcode = iimPlay(macro);
keyword = iimGetLastExtract();
// search for this keyword
macro = "CODE:";
macro += "TAG POS=1 TYPE=* ATTR=TXT:" + keyword + "\n";
retcode = iimPlay(macro);
// if retcode is 1 then the tag was found move on to next step
if (retcode === 1){
// move on to next step
aTagWasFound = true;
break;
}
// tag not found try the next value
}
if (!aTagWasFound)
{
alert("No keyword found");
} else
{
alert("Tag Found");
}