iMacros javascript nested loops in firefox

半城伤御伤魂 提交于 2019-12-12 02:56:42

问题


I have 2 macros I need to run in Firefox. They both run perfectly as iim's but I need to get them to run together

Macro1: It reads a text file with a number of links on it, loads the link, and moves on to the next

var macro1 = "CODE:";
macro1 += "VERSION BUILD=8300326 RECORDER=FX" + "\n";
macro1 += "" + "\n";
macro1 += "SET !DATASOURCE C:\\Users\\user1\\Documents\\REPORT_LINK_EXT_OBG.TXT" + "\n";
macro1 += "SET !DATASOURCE_LINE {{!LOOP}}" + "\n";
macro1 += "URL GOTO={{!COL1}}" + "\n";

Macro2: Extracts links for each page that macro1 opens. Problem is, there can be anywhere from 1 to 50 links that macro 2 needs to extract before macro1 moves on again.

var macro2 = "CODE:";
macro2 += "VERSION BUILD=7500718 RECORDER=FX" + "\n";
macro2 += "SET !TIMEOUT_TAG 2" + "\n";
macro2 += "SET !LOOP 2" + "\n";
macro2 += "SET !EXTRACT_TEST_POPUP NO" + "\n";
macro2 += "TAG POS={{!LOOP}} TYPE=A ATTR=HREF:*WeldDataLog.aspx?* EXTRACT=HREF" + "\n";
macro2 += "TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:aspnetForm ATTR=ID:ctl00_Main_ucReportHeader_pnlView_txtReportNumber EXTRACT=TXT" + "\n";
macro2 += "'----------------------------------\\/\\/\\/\\/\\/----Change this" + "\n";
macro2 += "SAVEAS TYPE=EXTRACT FOLDER=C:\\Users\\user1\\Documents FILE=LINK_EXT3test.TXT" + "\n";

I essentially need

Do macro1 Do macro2 Loop Loop

Can anyone help me get these 2 macros to work with instead of against each other?


回答1:


iimPlay(macro1)

var link1=iimGetLastExtract();

var link2_array=new Array();

for(var i=0; i<50; i++)
{

iimPlay(macro2)
link2_array[i]=iimGetLastExtract();


}

Would something like this work for you?

To check if the link is extracted properly you can use this

iimPlay(macro)
var link=iimGetLastExtract();

if(link=="EANF")
{

//link is not there

}
else
{

// link is there

}

To change position of imacros command.

var macro;

macro ="CODE:";
macro +="TAG POS={{n}} TYPE=A ATTR=HREF:someurl.com EXTRACT=HREF";

for (var i=1;i<=10;i++)
{

iimSet("n",i)
iimPlay(macro)

}


来源:https://stackoverflow.com/questions/16573127/imacros-javascript-nested-loops-in-firefox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!