Repeat line until no more attributes are found

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
Macron313
Posts: 4
Joined: Mon Sep 03, 2018 3:58 pm

Repeat line until no more attributes are found

Post by Macron313 » Mon Sep 03, 2018 4:17 pm

Hi. I am somewhat new to more advanced iMacro task. I have a .iim I am running on a site where you must click "see more" for the page to continue to load. Is there anyway for me to repeat that line until "see more" does not appear and then move on to the next line of the .iim? I have really the same question with extraction. Sometimes I do not know how many attributes will be on the page to extract, is there anyway to setup the .iim extract line so it will continue to extract until the last attribute is found and then move on to the next line? (Sorry for my English, it is not my primary language).

Here is my code so far. "See more" issue is line 10 and the extract issue is line 12

Code: Select all

1  VERSION BUILD=9030808
2  SET !ERRORIGNORE YES
3  TAB T=1
4  TAG POS=1 TYPE=A ATTR=CLASS:"_5pcq" EXTRACT=HREF
5  TAG POS=1 TYPE=DIV ATTR=CLASS:"_5pbx userContent _3576" EXTRACT=TXT
6  TAG POS=1 TYPE=A ATTR=CLASS:"mbs _6m6 _2cnj _5s6c" EXTRACT=HREF
7  TAG POS=1 TYPE=A ATTR=CLASS:"mbs _6m6 _2cnj _5s6c" EXTRACT=TXT
8  TAG POS=1 TYPE=SPAN ATTR=CLASS:_4arz
9  WAIT SECONDS=4
10 TAG POS=5 TYPE=A ATTR=TXT:See<SP>More
11 WAIT SECONDS=4
12 TAG POS=R1 TYPE=A ATTR=CLASS:"_5i_s _8o _8r lfloat _ohe" EXTRACT=HREF
13 SAVEAS TYPE=EXTRACT FOLDER=C:\scrape\ FILE=GWpage.HTM

Thank you for any suggestions.
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Repeat line until no more attributes are found

Post by chivracq » Mon Sep 03, 2018 4:54 pm

Macron313 wrote:Hi. I am somewhat new to more advanced iMacro task. I have a .iim I am running on a site where you must click "see more" for the page to continue to load. Is there anyway for me to repeat that line until "see more" does not appear and then move on to the next line of the .iim? I have really the same question with extraction. Sometimes I do not know how many attributes will be on the page to extract, is there anyway to setup the .iim extract line so it will continue to extract until the last attribute is found and then move on to the next line? (Sorry for my English, it is not my primary language).

Here is my code so far. "See more" issue is line 10 and the extract issue is line 12

Code: Select all

1  VERSION BUILD=9030808
2  SET !ERRORIGNORE YES
3  TAB T=1
4  TAG POS=1 TYPE=A ATTR=CLASS:"_5pcq" EXTRACT=HREF
5  TAG POS=1 TYPE=DIV ATTR=CLASS:"_5pbx userContent _3576" EXTRACT=TXT
6  TAG POS=1 TYPE=A ATTR=CLASS:"mbs _6m6 _2cnj _5s6c" EXTRACT=HREF
7  TAG POS=1 TYPE=A ATTR=CLASS:"mbs _6m6 _2cnj _5s6c" EXTRACT=TXT
8  TAG POS=1 TYPE=SPAN ATTR=CLASS:_4arz
9  WAIT SECONDS=4
10 TAG POS=5 TYPE=A ATTR=TXT:See<SP>More
11 WAIT SECONDS=4
12 TAG POS=R1 TYPE=A ATTR=CLASS:"_5i_s _8o _8r lfloat _ohe" EXTRACT=HREF
13 SAVEAS TYPE=EXTRACT FOLDER=C:\scrape\ FILE=GWpage.HTM
Thank you for any suggestions.
(F)CIM...! :mrgreen: ... for me to have a look... (Read my Sig...)
(+ If using v10.0.x for CR/FF, mention as well 'Free'/'PE'... Hum, will be 'PE' of course (because of the 'SAVEAS'), ah-ah...! :wink: )
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Macron313
Posts: 4
Joined: Mon Sep 03, 2018 3:58 pm

Re: Repeat line until no more attributes are found

Post by Macron313 » Mon Sep 03, 2018 5:25 pm

Sorry. iMacro 9.03 running on FireFox version 52.0 on Windows 10 pro.

It is the same iMacro version I have been running for some time. Last time I updated it was a mess. Don't want to go through that again.
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Repeat line until no more attributes are found

Post by chivracq » Mon Sep 03, 2018 5:53 pm

Macron313 wrote:Sorry.

Code: Select all

iMacro 9.03 running on FireFox version 52.0 on Windows 10 pro.
OK, perfect...! :D
(Correct Spelling is "iMacros" btw... :wink: )

OK then, as you are "indeed" on v9.0.3 for FF, the most "straightforward" Solution for you would be to use a (main) '.js' Script and to "split" your current '.iim' Macro into 3 parts I would say, where you would (nested) loop the last 2 parts (about scrolling with the 'See more' Link and extracting your "Attributes"...).
+ The same "Principle" would also be my "Answer" to your parallel/related Thread on SOF for which this current Thread on our Forum seems to be a "Follow-up" after making already some "Progress"... (Hum, you could mention your FCI and try to spell "iMacros" correctly on SOF as well... :wink: )

"Stg" (= something) to take into consideration, is that if you ever want/need to update FF from your current FF52 Version, to past FF57(+) (current FF Version is now FF62, as of Aug 2018), you will then need to update/upgrade iMacros to v10.0.2(+) (as v8.9.7 + v9.0.3 only work until FF56), but '.js' Scripts are not supported anymore/yet on v10.0.2, then you would need to "go back" to a "Solution" in pure '.iim'...
EDIT, as I notice that you had edited your previous Post in the meantime that I was typing my own Reply...:
Macron313 wrote:It is the same iMacro version I have been running for some time. Last time I updated it was a mess. Don't want to go through that again.
=> OK, you already seem to be a bit "aware" of the "Implications" about which and which Version(s) to use and their "Limitations"... :wink:

It is possible to implement the Functionality that you want in pure '.iim', by looping your "current" '.iim' Script (with a few Changes of course...), but it would be a little bit "cumbersome"..., as you will need to conditionally "mute" certain parts of the whole Script so that only the "needed" part for a specific Loop does "stg" (like clicking on the 'See more' Link an/or only extracting one Element), but hum, like I said, it's a bit cumbersome..., but it can be done... :twisted:
=> With '!ERRORIGNORE' that you already use, + a short '!TIMEOUT_STEP' (=0), and + "switching off" in block all unneeded 'POS=1' for one Loop to 'POS=0' (with 'EVAL()') as 'POS=0' won't do anything, and + conditionally toggling your 'WAIT' Statements between [0-4] depending on if a Loop needs to wait for the 4 Secs or not...

If updating/upgrading to v10.0.2 one day, you will need the 'PE' Version ('Personal Edition') which is not Free anymore as you need the Local File-Access for the 'SAVEAS' Command, so if you intend to "stay" on v9.0.3 for FF as long as possible (hum, and v8.9.7 in this case is even more "Stable" than v9.0.3...), the "recommended" Path would be to use a '.js' Script then, I guess... (And you'll find many Examples on the Forum then...) :wink:

Well, good "luck" and post your final Script, or if you get "stuck" in the "Process"... 8)
Last edited by chivracq on Mon Sep 03, 2018 7:28 pm, edited 2 times in total.
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Macron313
Posts: 4
Joined: Mon Sep 03, 2018 3:58 pm

Re: Repeat line until no more attributes are found

Post by Macron313 » Mon Sep 03, 2018 7:18 pm

Thank you chivracq! Would recommended any guides or tutorials that speak to JS scripts in iMacros? I have seen people speak of it but not a lot of documentation on it. I will post my final script so if other people have the same issue they can learn from my experience. Thank you.
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Repeat line until no more attributes are found

Post by chivracq » Mon Sep 03, 2018 7:34 pm

Macron313 wrote:Thank you chivracq! Would recommended any guides or tutorials that speak to JS scripts in iMacros? I have seen people speak of it but not a lot of documentation on it. I will post my final script so if other people have the same issue they can learn from my experience. Thank you.
[I edited a bit my previous Post while you were posting this one, you may want to refresh the Page, ah-ah...!]

Hum, "guides or tutorials", I don't really know to be honest, as I don't use any '.js' Scripts myself, I prefer to do all my Coding in pure '.iim', even if I'm also on FF (using v8.8.2 + v8.9.7)..., but I know the Forum is full-full-full of many '.js' (Code) Examples and related/similar Threads... (Search on "nested+loop/loops/looping+js/javascript... :idea: )
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Macron313
Posts: 4
Joined: Mon Sep 03, 2018 3:58 pm

Re: Repeat line until no more attributes are found

Post by Macron313 » Mon Sep 03, 2018 7:49 pm

Thank you for the recommended search terms! I think my iMacros nomenclature is off so sometimes it is hard for me to search for what I am looking for. The pure way with no JS might be easier for me because I have never worked with JS. Would you have any recommended search terms for the Pure way to do it?
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Repeat line until no more attributes are found

Post by chivracq » Mon Sep 03, 2018 8:12 pm

Macron313 wrote:Thank you for the recommended search terms! I think my iMacros nomenclature is off so sometimes it is hard for me to search for what I am looking for. The pure way with no JS might be easier for me because I have never worked with JS. Would you have any recommended search terms for the Pure way to do it?
Yeah well, if you want to implement it in pure '.iim', which is very possible indeed like I already mentioned, and your Script is "luckily" pretty short (my own Scripts are usually 1000-5000-8000 Lines long, then I wouldn't loop a 5000 Line Script if I only need 2 Lines to actually "do stg", ah-ah...!, although I don't always need the full 5000 Lines to be processed, so some "Sections" do get (cascaded) "muted" when needed), and I already gave you the "Principle" I use:
chivracq wrote:=> With '!ERRORIGNORE' that you already use, + a short '!TIMEOUT_STEP' (=0), and + "switching off" in block all unneeded 'POS=1' for one Loop to 'POS=0' (with 'EVAL()') as 'POS=0' won't do anything, and + conditionally toggling your 'WAIT' Statements between [0-4] depending on if a Loop needs to wait for the 4 Secs or not...
Some more Info about all the Techniques you'll need and that I have already enumerated and explained a bit in the following Thread, where I maintain also a bit of a "Collection" of related/'interesting" Threads... 8) :
- Workarounds for Conditional Logic in Macro Code
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Post Reply