iMacros How to extract dynamic table rows with loop & stop when reach a specific condition

Viewed 19

Google Chrome: Version 105.0.5195.102 (Official Build) (64-bit)

iMacros: 2021

System: Windows 10 Pro 21H2 19044.1949

With Guru chivracq kind guidance from my earlier post https://forum.imacros.net/viewtopic.php?f=7&t=32028, i'm able to extract required data with unique element style="background-color: orange;" by using 'Double Relative Positioning' instead of using Xpath.

Since the data table is dynamic with 15mins refresh interval, the total of rows will change from each refresh. I've tried to search for solution & study eval() from the forum posts (especially Guru chivracq solutions) but i'm still not able to grasp the technic somehow.

Here again, I hope to have more guidance to find the solution.

Questions:-

  • Is there a way to make a loop instead of the way i'm using as per code below eg. 'Extract 1st rows, 'Extract 2nd rows and so on?
  • The extraction should be stopped when reached <tr class="montage_atm_bottom even", how can i achieve this?

My current code:-

TAG POS=1 TYPE=TD ATTR=STYLE:"background-color: orange;"
TAG POS=R-1 TYPE=* ATTR=* EXTRACT=TXT
SET !EXTRACT NULL

'Extract 1st rows
TAG POS=R1 TYPE=A ATTR=CLASS:montagelink EXTRACT=TXT
TAG POS=R1 TYPE=TD ATTR=CLASS:rightcelltd<SP>volcell EXTRACT=TXT
TAG POS=R1 TYPE=TD ATTR=CLASS:rightcelltd<SP>volcell EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=C:\Users\Desktop FILE=test_{{!NOW:yymmdd_hhnn}}.csv

'Extract 2nd rows
TAG POS=R1 TYPE=TD ATTR=CLASS:descriptorcell
TAG POS=R1 TYPE=A ATTR=CLASS:montagelink EXTRACT=TXT
TAG POS=R1 TYPE=TD ATTR=CLASS:rightcelltd<SP>volcell EXTRACT=TXT
TAG POS=R1 TYPE=TD ATTR=CLASS:rightcelltd<SP>volcell EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=C:\Users\Desktop FILE=test_{{!NOW:yymmdd_hhnn}}.csv

'Extract 3rd rows
TAG POS=R1 TYPE=TD ATTR=CLASS:descriptorcell
TAG POS=R1 TYPE=A ATTR=CLASS:montagelink EXTRACT=TXT
TAG POS=R1 TYPE=TD ATTR=CLASS:rightcelltd<SP>volcell EXTRACT=TXT
TAG POS=R1 TYPE=TD ATTR=CLASS:rightcelltd<SP>volcell EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=C:\Users\Desktop FILE=test_{{!NOW:yymmdd_hhnn}}.csv

'Extract 4th rows..
'Extract 5th rows.. 




0 Answers
Related