iimGetExtract() result undefined

Discussions and Tech Support related to website data extraction, screen scraping and data mining using iMacros.
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
Cornysz
Posts: 21
Joined: Sun Apr 12, 2020 1:48 pm

iimGetExtract() result undefined

Post by Cornysz » Sat Apr 18, 2020 4:17 pm

BUILD=8970419
Freeware
Win 10
Firefox 56

So i want to replace commas to space in my EXTRACT, but in the .csv i got undefined string :shock: How to fix this?

This is part of my code (.js)

Code: Select all

for (var i=1;i<50;i++){
iimSet("i",i)
macro += "TAG POS={{i}} TYPE=DIV ATTR=class:O6wiAW* EXTRACT=TXT" + "\n";
VAR3 = iimGetExtract().replace(/[ ]*,[ ]*|[ ]+/g, ' ');
iimSet("VAR3",VAR3)
macro += "SET Va1 {{!VAR3}}" + "\n";
...
If without .replace, the result is correct, not undefined.
I'm still newbie :? Thanks in advance :)
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: iimGetExtract() result undefined

Post by chivracq » Sat Apr 18, 2020 4:25 pm

Cornysz wrote:
Sat Apr 18, 2020 4:17 pm

Code: Select all

BUILD=8970419 Freeware
Win 10
Firefox 56
So i want to replace commas to space in my EXTRACT, but in the .csv i got undefined string :shock: How to fix this?

This is part of my code (.js)

Code: Select all

for (var i=1;i<50;i++){
iimSet("i",i)
macro += "TAG POS={{i}} TYPE=DIV ATTR=class:O6wiAW* EXTRACT=TXT" + "\n";
VAR3 = iimGetExtract().replace(/[ ]*,[ ]*|[ ]+/g, ' ');
iimSet("VAR3",VAR3)
macro += "SET Va1 {{!VAR3}}" + "\n";
...
If without .replace, the result is correct, not undefined.
I'm still newbie :? Thanks in advance :)

Because "VAR3" <> "!VAR3" => Both '!VAR3' & 'Va1' are Undefined... :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...
Cornysz
Posts: 21
Joined: Sun Apr 12, 2020 1:48 pm

Re: iimGetExtract() result undefined

Post by Cornysz » Sat Apr 18, 2020 6:12 pm

Thank you for the anwer but i got "weird" error too, TypeError: iimGetExtract(...) is undefined, line 12 (Error code: -991). But, to fix this i need to run other worked script and then i can run that script without that "weird" bug. What causes of this problem? and how to fix it?

And i tried to fix problem in above with this

Code: Select all

macro += "TAG POS={{i}} TYPE=DIV ATTR=class:O6wiAW* EXTRACT=TXT" + "\n";
VAR3 = iimGetExtract().replace(/[ ]*,[ ]*|[ ]+/g, ' ');
iimSet("varnama",VAR3)
macro += "SET Va1 {{varnama}}" + "\n";
..
macro += "SET !EXTRACT {{Va1}}" + "\n";
macro += "SAVEAS TYPE=EXTRACT FOLDER=* FILE=kornismacro.csv" + "\n";
But still result "undefined" in my .csv file :(
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: iimGetExtract() result undefined

Post by chivracq » Sat Apr 18, 2020 7:27 pm

Cornysz wrote:
Sat Apr 18, 2020 6:12 pm
Thank you for the anwer but i got "weird" error too, TypeError: iimGetExtract(...) is undefined, line 12 (Error code: -991). But, to fix this i need to run other worked script and then i can run that script without that "weird" bug. What causes of this problem? and how to fix it?

And i tried to fix problem in above with this

Code: Select all

macro += "TAG POS={{i}} TYPE=DIV ATTR=class:O6wiAW* EXTRACT=TXT" + "\n";
VAR3 = iimGetExtract().replace(/[ ]*,[ ]*|[ ]+/g, ' ');
iimSet("varnama",VAR3)
macro += "SET Va1 {{varnama}}" + "\n";
..
macro += "SET !EXTRACT {{Va1}}" + "\n";
macro += "SAVEAS TYPE=EXTRACT FOLDER=* FILE=kornismacro.csv" + "\n";
But still result "undefined" in my .csv file :(

Yeah, but difficult to help you from mini-bits of your Script, post the full Script...!, I can't follow what you are doing and see what you can be doing wrong..., I don't see any 'iimPlay()' or 'iimPlayCode()' for example, then no wonder that 'iimGetExtract()' will be undefined...

And the mini-bits that I can see already look pretty cumbersome, like giving 3 different Names for a same Var... ("VAR3" => "varnama" => "Va1") :?

>>>

I rarely see a "good Reason" anyway for using a '.js' Script, that I find very cumbersome, and I don't use any myself, and never have...!, I do all my Web-Automation with iMacros in pure '.iim', and I do more "Complex" and more "Advanced" "Things" in my Scripts than most Users I've ever seen doing on this Forum, even with '.js' Scripts or with the 'SI' (Scripting Interface)... :twisted:
And you didn't follow up anymore in your previous Thread, but in "your Case", using a '.js' Script looks very-very cumbersome to me, I would think... :shock:
- (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...
Cornysz
Posts: 21
Joined: Sun Apr 12, 2020 1:48 pm

Re: iimGetExtract() result undefined

Post by Cornysz » Sun Apr 19, 2020 3:12 am

chivracq wrote:
Sat Apr 18, 2020 7:27 pm
Yeah, but difficult to help you from mini-bits of your Script, post the full Script...!, I can't follow what you are doing and see what you can be doing wrong..., I don't see any 'iimPlay()' or 'iimPlayCode()' for example, then no wonder that 'iimGetExtract()' will be undefined...
OKay, sorry i usually post my part of code to ask somehting hehe :wink:

And this is my full script, I'm still newbie about code, so i can't code with effective way

Code: Select all

var macro;
macro = "CODE:";
macro += "VERSION BUILD=8970419 RECORDER=FX" + "\n";
macro += "SET !EXTRACT_TEST_POPUP NO" + "\n";
macro += "TAB T=1" + "\n";
//'SET !LOOP 1'
//'SET !VAR1 1'

for (var i=1;i<50;i++){
iimSet("i",i)
macro += "TAG POS={{i}} TYPE=DIV ATTR=class:O6wiAW* EXTRACT=TXT" + "\n";
VAR3 = iimGetExtract().replace(/[ ]*,[ ]*|[ ]+/g, ' ');
iimSet("varnama",VAR3)
macro += "SET Va1 {{varnama}}" + "\n";

//'harga"'
macro += "SET !EXTRACT NULL" + "\n";
macro += "TAG POS={{i}} TYPE=SPAN ATTR=class:_341bF0 EXTRACT=TXT" + "\n";
VAR1 = iimGetLastExtract().replace(/\\n/g,'');
VAR2 = VAR1.replace(/\s\s+/g,'');
macro += "SET Va2 {{!VAR2}}" + "\n";

//'terju"al'
macro += "SET !EXTRACT NULL" + "\n";
macro += "TAG POS={{i}} TYPE=DIV ATTR=class:_18SLBt EXTRACT=TXT" + "\n";
VAR1 = iimGetLastExtract().replace(/\\n/g,'');
VAR2 = VAR1.replace(/\s\s+/g,'');
macro += "SET Va3 {{!VAR2}}" + "\n";

//'link'"" + "\n";
macro += "SET !EXTRACT NULL" + "\n";
macro += "TAG POS={{i}} TYPE=A ATTR=DATA-SQE:link&&HREF:https://shopee.co.id/* EXTRACT=HREF" + "\n";
VAR1 = iimGetLastExtract().replace(/\\n/g,'');
VAR2 = VAR1.replace(/\s\s+/g,'');
macro += "SET url {{!VAR2}}" + "\n";

//'kota'
macro += "SET !EXTRACT NULL" + "\n";
macro += "TAG POS={{i}} TYPE=DIV ATTR=class:_3amru2 EXTRACT=TXT" + "\n";
VAR1 = iimGetLastExtract().replace(/\\n/g,'');
VAR2 = VAR1.replace(/\s\s+/g,'');
macro += "SET Va4 {{!VAR2}}" + "\n";

macro += "SET !EXTRACT NULL" + "\n";
macro += "SET !EXTRACT {{Va1}}" + "\n";
macro += "ADD !EXTRACT {{Va2}}" + "\n";
macro += "ADD !EXTRACT {{Va3}}" + "\n";
macro += "ADD !EXTRACT {{url}}" + "\n";
macro += "ADD !EXTRACT {{Va4}}" + "\n";
macro += "SAVEAS TYPE=EXTRACT FOLDER=* FILE=kornismacro.csv" + "\n";
iimPlay(macro);
};
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: iimGetExtract() result undefined

Post by chivracq » Sun Apr 19, 2020 10:10 am

Cornysz wrote:
Sun Apr 19, 2020 3:12 am
chivracq wrote:
Sat Apr 18, 2020 7:27 pm
Yeah, but difficult to help you from mini-bits of your Script, post the full Script...!, I can't follow what you are doing and see what you can be doing wrong..., I don't see any 'iimPlay()' or 'iimPlayCode()' for example, then no wonder that 'iimGetExtract()' will be undefined...
OKay, sorry i usually post my part of code to ask somehting hehe :wink:

And this is my full script, I'm still newbie about code, so i can't code with effective way

Code: Select all

var macro;
macro = "CODE:";
macro += "VERSION BUILD=8970419 RECORDER=FX" + "\n";
macro += "SET !EXTRACT_TEST_POPUP NO" + "\n";
macro += "TAB T=1" + "\n";
//'SET !LOOP 1'
//'SET !VAR1 1'

for (var i=1;i<50;i++){
iimSet("i",i)
macro += "TAG POS={{i}} TYPE=DIV ATTR=class:O6wiAW* EXTRACT=TXT" + "\n";
VAR3 = iimGetExtract().replace(/[ ]*,[ ]*|[ ]+/g, ' ');
iimSet("varnama",VAR3)
macro += "SET Va1 {{varnama}}" + "\n";

//'harga"'
macro += "SET !EXTRACT NULL" + "\n";
macro += "TAG POS={{i}} TYPE=SPAN ATTR=class:_341bF0 EXTRACT=TXT" + "\n";
VAR1 = iimGetLastExtract().replace(/\\n/g,'');
VAR2 = VAR1.replace(/\s\s+/g,'');
macro += "SET Va2 {{!VAR2}}" + "\n";

//'terju"al'
macro += "SET !EXTRACT NULL" + "\n";
macro += "TAG POS={{i}} TYPE=DIV ATTR=class:_18SLBt EXTRACT=TXT" + "\n";
VAR1 = iimGetLastExtract().replace(/\\n/g,'');
VAR2 = VAR1.replace(/\s\s+/g,'');
macro += "SET Va3 {{!VAR2}}" + "\n";

//'link'"" + "\n";
macro += "SET !EXTRACT NULL" + "\n";
macro += "TAG POS={{i}} TYPE=A ATTR=DATA-SQE:link&&HREF:https://shopee.co.id/* EXTRACT=HREF" + "\n";
VAR1 = iimGetLastExtract().replace(/\\n/g,'');
VAR2 = VAR1.replace(/\s\s+/g,'');
macro += "SET url {{!VAR2}}" + "\n";

//'kota'
macro += "SET !EXTRACT NULL" + "\n";
macro += "TAG POS={{i}} TYPE=DIV ATTR=class:_3amru2 EXTRACT=TXT" + "\n";
VAR1 = iimGetLastExtract().replace(/\\n/g,'');
VAR2 = VAR1.replace(/\s\s+/g,'');
macro += "SET Va4 {{!VAR2}}" + "\n";

macro += "SET !EXTRACT NULL" + "\n";
macro += "SET !EXTRACT {{Va1}}" + "\n";
macro += "ADD !EXTRACT {{Va2}}" + "\n";
macro += "ADD !EXTRACT {{Va3}}" + "\n";
macro += "ADD !EXTRACT {{url}}" + "\n";
macro += "ADD !EXTRACT {{Va4}}" + "\n";
macro += "SAVEAS TYPE=EXTRACT FOLDER=* FILE=kornismacro.csv" + "\n";
iimPlay(macro);
};

Alright, now I understand what you are doing / trying to do..., but pfff..., "How to make Things complicated when they could be simple...!", ah-ah...! :shock:

Alright, at least you have 1x 'iimPlay()' Command, but only at the end of your Script, not good...!, "the" Mistake you are making is that you are trying to use 'iimGetExtract()' (same with (deprecated) 'iimGetLastExtract()' that you are also using...) inside/before 'iimPlay()'... But nope...!, iimGetExtract()' is a "Result" of an 'iimPlay()' Command, so it needs to come after and not before...! :!:
=> That means you will have to split your whole Logic into at least 5x Sub-Macros, hum, probably 6x, and each with their own 'iimPlay()' Execution.

One Thing you are doing correctly, and I'm "nearly" impressed, ah-ah...! :o , is to do all the 'replace()' Operations directly at the '.js' Level and not in 'EVAL()' in the on-the-fly '.iim' Script(s) like many Users "stupidly"/cumbersomely do, because good luck otherwise with finding the right Escape Syntax for your "/\\n/g" + "/\s\s+/g", ah-ah...! :lol:

But hum, wait..., you are a bit "lucky"... OK, you only need to split your Logic into 2x Sub-Scripts, one with all Extracts in a row, and you can access all 5x Extracts separately with "iimGetExtract(n)"with 'n' in '[1-5]' or '[0-4]', I'm not sure, hum, '[1-5]' I think, as the "0" is reserved for "All" I think...), to do then all 5x 'replace()', and then pass those 5x Vars/Results to a 2nd '.iim' Script (with its own 'iimPlay()') for the final 'SAVEAS'.

>>>

And yep, I know..., I'm quoting myself again, but on purpose, it's a very short Inner-Quote, and it's relevant for reading the Thread without having to scroll up again... :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...
Cornysz
Posts: 21
Joined: Sun Apr 12, 2020 1:48 pm

Re: iimGetExtract() result undefined

Post by Cornysz » Sun Apr 19, 2020 4:28 pm

Okay thank you for the asnwer, after i check my script, i just figured it out i have 1 problem, the problem is how to replace commas to space?

Code: Select all

macro += "TAG POS={{i}} TYPE=DIV ATTR=class:O6wiAW* EXTRACT=TXT" + "\n";
VAR3 = iimGetExtract().replace(/[ ]*,[ ]*|[ ]+/g, ' ');
I have that part of my script, i want the result of extract replaced the commas (,) to space. How to do that in .js script?
*i deleted other .replace bcs it is unnecesary :lol:
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: iimGetExtract() result undefined

Post by chivracq » Sun Apr 19, 2020 7:41 pm

Cornysz wrote:
Sun Apr 19, 2020 4:28 pm
Okay thank you for the asnwer, after i check my script, i just figured it out i have 1 problem, the problem is how to replace commas to space?

Code: Select all

macro += "TAG POS={{i}} TYPE=DIV ATTR=class:O6wiAW* EXTRACT=TXT" + "\n";
VAR3 = iimGetExtract().replace(/[ ]*,[ ]*|[ ]+/g, ' ');
I have that part of my script, i want the result of extract replaced the commas (,) to space. How to do that in .js script?
*i deleted other .replace bcs it is unnecesary :lol:

Yeah, but before moving to some next part, can you first react to my previous Reply and post the next Version of your Script and what you did with my Remarks about your Use of 'iimGetExtract()' + 'iimPlay()' + the overall Logic of your Script...?

I won't answer your Threads/Qt's anymore if you each time more or less ignore my Replies and only ask some new Qt... :|
- (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...
Cornysz
Posts: 21
Joined: Sun Apr 12, 2020 1:48 pm

Re: iimGetExtract() result undefined

Post by Cornysz » Mon Apr 20, 2020 3:34 am

chivracq wrote:
Sun Apr 19, 2020 7:41 pm
Yeah, but before moving to some next part, can you first react to my previous Reply and post the next Version of your Script and what you did with my Remarks about your Use of 'iimGetExtract()' + 'iimPlay()' + the overall Logic of your Script...?
Yeah, i did many things for my script, and i realized so many useless line of code, like .replace, wrong for function { }, etc (i'm learning from youtube & and following every part without think it first, this is my fault :? ) And yeah, after many hours experimenting my script, i figured it out just need my QT in above. Thank you in advance.
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: iimGetExtract() result undefined

Post by chivracq » Mon Apr 20, 2020 3:46 am

Cornysz wrote:
Mon Apr 20, 2020 3:34 am
chivracq wrote:
Sun Apr 19, 2020 7:41 pm
Yeah, but before moving to some next part, can you first react to my previous Reply and post the next Version of your Script and what you did with my Remarks about your Use of 'iimGetExtract()' + 'iimPlay()' + the overall Logic of your Script...?
Yeah, i did many things for my script, and i realized so many useless line of code, like .replace, wrong for function { }, etc (i'm learning from youtube & and following every part without think it first, this is my fault :? ) And yeah, after many hours experimenting my script, i figured it out just need my QT in above. Thank you in advance.

Yeah well, "I figured it out", perfect...! Then post your next Version of your Script to "show" how you "figured it out", and to make this Thread useful for other Users with a Solution and a Script Sample...! :roll:

When I help Users and answer Threads on the Forum, I don't do it "only" for the User starting the Thread (=> you in this case), but for the whole Community, and for other Users who will find this Thread useful from your Scenario and the Start-Script you had, and what it became to the "Final-Script" with Improvements and Solution(s), that they can then use as an Example... Just like you were/are looking for Examples to make your own Script... :idea:

Hum..., and 'YouTube' is really not the best place to learn about iMacros and find "useful" and "correct" Script Samples, most Videos and Channels about iMacros on 'YT' are a bit "Fake" and Click-Bait in my "Experience", from the few I ever checked... :(
- (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...
Cornysz
Posts: 21
Joined: Sun Apr 12, 2020 1:48 pm

Re: iimGetExtract() result undefined

Post by Cornysz » Mon Apr 20, 2020 5:24 am

chivracq wrote:
Mon Apr 20, 2020 3:46 am

When I help Users and answer Threads on the Forum, I don't do it "only" for the User starting the Thread (=> you in this case), but for the whole Community, and for other Users who will find this Thread useful from your Scenario and the Start-Script you had, and what it became to the "Final-Script" with Improvements and Solution(s), that they can then use as an Example... Just like you were/are looking for Examples to make your own Script... :idea:

Hum..., and 'YouTube' is really not the best place to learn about iMacros and find "useful" and "correct" Script Samples, most Videos and Channels about iMacros on 'YT' are a bit "Fake" and Click-Bait in my "Experience", from the few I ever checked... :(
Okay this is my final script, many changes compare to my old script.

Code: Select all

var macro;
macro = "CODE:";
macro += "VERSION BUILD=8970419 RECORDER=FX" + "\n";
macro += "SET !EXTRACT_TEST_POPUP NO" + "\n";
macro += "TAB T=1" + "\n";

macro += "TAG POS={{i}} TYPE=DIV ATTR=class:O6wiAW* EXTRACT=TXT" + "\n";
macro += "SET Va1 {{!EXTRACT}}" + "\n";

macro += "SET !EXTRACT NULL" + "\n";
macro += "TAG POS={{i}} TYPE=SPAN ATTR=class:_341bF0 EXTRACT=TXT" + "\n";
macro += "SET Va2 {{!EXTRACT}}" + "\n";

macro += "SET !EXTRACT NULL" + "\n";
macro += "TAG POS={{i}} TYPE=DIV ATTR=class:_18SLBt EXTRACT=TXT" + "\n";
macro += "SET Va3 {{!EXTRACT}}" + "\n";

macro += "SET !EXTRACT NULL" + "\n";
macro += "TAG POS={{i}} TYPE=A ATTR=DATA-SQE:link&&HREF:https://shopee.co.id/* EXTRACT=HREF" + "\n";
macro += "SET url {{!EXTRACT}}" + "\n";

macro += "SET !EXTRACT NULL" + "\n";
macro += "TAG POS={{i}} TYPE=DIV ATTR=class:_3amru2 EXTRACT=TXT" + "\n";
macro += "SET Va4 {{!EXTRACT}}" + "\n";

macro += "SET !EXTRACT NULL" + "\n";
macro += "SET !EXTRACT {{Va1}}" + "\n";
macro += "ADD !EXTRACT {{Va2}}" + "\n";
macro += "ADD !EXTRACT {{Va3}}" + "\n";
macro += "ADD !EXTRACT {{url}}" + "\n";
macro += "ADD !EXTRACT {{Va4}}" + "\n";
macro += "SAVEAS TYPE=EXTRACT FOLDER=* FILE=kornismacro.csv" + "\n";

for (var i=1;i<6;i++){
iimSet("i",i)
iimPlay(macro);
};
And yeah, same question, about replace in above, how to do that? :wink:
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: iimGetExtract() result undefined

Post by chivracq » Mon Apr 20, 2020 1:38 pm

Cornysz wrote:
Mon Apr 20, 2020 5:24 am
Okay this is my final script, many changes compare to my old script.

Code: Select all

var macro;
macro = "CODE:";
macro += "VERSION BUILD=8970419 RECORDER=FX" + "\n";
macro += "SET !EXTRACT_TEST_POPUP NO" + "\n";
macro += "TAB T=1" + "\n";

macro += "TAG POS={{i}} TYPE=DIV ATTR=class:O6wiAW* EXTRACT=TXT" + "\n";
macro += "SET Va1 {{!EXTRACT}}" + "\n";

macro += "SET !EXTRACT NULL" + "\n";
macro += "TAG POS={{i}} TYPE=SPAN ATTR=class:_341bF0 EXTRACT=TXT" + "\n";
macro += "SET Va2 {{!EXTRACT}}" + "\n";

macro += "SET !EXTRACT NULL" + "\n";
macro += "TAG POS={{i}} TYPE=DIV ATTR=class:_18SLBt EXTRACT=TXT" + "\n";
macro += "SET Va3 {{!EXTRACT}}" + "\n";

macro += "SET !EXTRACT NULL" + "\n";
macro += "TAG POS={{i}} TYPE=A ATTR=DATA-SQE:link&&HREF:https://shopee.co.id/* EXTRACT=HREF" + "\n";
macro += "SET url {{!EXTRACT}}" + "\n";

macro += "SET !EXTRACT NULL" + "\n";
macro += "TAG POS={{i}} TYPE=DIV ATTR=class:_3amru2 EXTRACT=TXT" + "\n";
macro += "SET Va4 {{!EXTRACT}}" + "\n";

macro += "SET !EXTRACT NULL" + "\n";
macro += "SET !EXTRACT {{Va1}}" + "\n";
macro += "ADD !EXTRACT {{Va2}}" + "\n";
macro += "ADD !EXTRACT {{Va3}}" + "\n";
macro += "ADD !EXTRACT {{url}}" + "\n";
macro += "ADD !EXTRACT {{Va4}}" + "\n";
macro += "SAVEAS TYPE=EXTRACT FOLDER=* FILE=kornismacro.csv" + "\n";

for (var i=1;i<6;i++){
iimSet("i",i)
iimPlay(macro);
};
And yeah, same question, about replace in above, how to do that? :wink:

Hum, OK, you didn't do much with the Comments/Recommendations I made about the Logic and Workflow of your Script... :o

The Process (x5) of isolating and storing each 'EXTRACT' into a Temp-Var, to then reconstruct the whole '!EXTRACT' Var has no real Use in your Case and doesn't do anything... It is only useful in pure '.iim', if you need to "clean" some Extract(s) with 'EVAL()', or want to reuse (part of) those Vars in a 'PROMPT' or some Log File, or want to reuse a single Var "later" in the Script, or want to change the Order of the Extract Sequence...

>>>

But hum, OK..., then about your "Replace Commas with Spaces" Functionality, well, that's not difficult to solve, you are the "Specialist" already I would think, as you already used some Global 'replace()' (x2) in the previous Version of your Script, and/or you would find the correct Syntax by searching the Forum and/or 'StackOverFlow' that probably contains Dozens of Examples...

But rather than using Global 'replace()', that I never use myself, as I find the Syntax a bit too complex, and always a hassle to find the right Escape Sequence, I prefer to use "split(',').join(' ')" which doesn't require any Special/Escape Chars (even in 'EVAL()' in pure '.iim' Scripts), applied to your specific Replace Functionality. :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...
Cornysz
Posts: 21
Joined: Sun Apr 12, 2020 1:48 pm

Re: iimGetExtract() result undefined

Post by Cornysz » Mon Apr 20, 2020 2:54 pm

chivracq wrote:
Mon Apr 20, 2020 1:38 pm
But rather than using Global 'replace()', that I never use myself, as I find the Syntax a bit too complex, and always a hassle to find the right Escape Sequence, I prefer to use "split(',').join(' ')" which doesn't require any Special/Escape Chars (even in 'EVAL()' in pure '.iim' Scripts), applied to your specific Replace Functionality. :idea:
Okay i can use .replace(","," ") too right? but i'm still confused the variable, i mean how to get the extract data and then .replace it in JS? extractvar.replace(","," "), what should i change the "extractvar"? In .iim file, to replace can with EVAL, but in JS i'm getting confused. i tried using

Code: Select all

macro += 'SET !VAR3 EVAL("\'{{!EXTRACT}}\'.replace(/[ ]*,[ ]*|[ ]+/g, ' ');")' + "\n"; 
that code but got error this SyntaxError: missing ; before statement, line 9 (Error code: -991)
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: iimGetExtract() result undefined

Post by chivracq » Mon Apr 20, 2020 3:27 pm

Cornysz wrote:
Mon Apr 20, 2020 2:54 pm
Okay i can use .replace(","," ") too right?

Yep, correct..., if you only expect 1 Occurrence of your Char/String to replace... The Global 'replace()' is "meant" if you expect multiple Occurrences.

And hum, I prefer to use "replace(',',' ')", => with Single Quotes around the 2 Arguments, as like I mentioned also for "split().join()", no Escaping is then needed in 'EVAL()' in pure '.iim'.
In pure JS, it doesn't matter, you can use both (Double Quotes or Single Quotes).

>>>
Cornysz wrote:
Mon Apr 20, 2020 2:54 pm
but i'm still confused the variable, i mean how to get the extract data and then .replace it in JS? extractvar.replace(","," "), what should i change the "extractvar"? In .iim file, to replace can with EVAL, but in JS i'm getting confused.

That was the part I mentioned earlier in some previous Reply that "you were doing correctly"..., with 'iimGetExtract()'.
And somewhere else, I mentioned that you would then need to access every single Extract with "iimGetExtract(n)" with 'n' in [1-5].

>>>
Cornysz wrote:
Mon Apr 20, 2020 2:54 pm
i tried using

Code: Select all

macro += 'SET !VAR3 EVAL("\'{{!EXTRACT}}\'.replace(/[ ]*,[ ]*|[ ]+/g, ' ');")' + "\n"; 
that code but got error this SyntaxError: missing ; before statement, line 9 (Error code: -991)

Yeah well, now this falls into the part where I mentioned in some previous Reply that I consider using 'EVAL()' in an on-the-fly Generated '.iim' Macro => "stupid"/cumbersome..., well I mean(t) "not Best Practice" for the least... :( , and I wished you "Good Luck with finding the correct (Escape) Syntax", ah-ah...! (... as this is a complete Russian Roulette with the Number of Escape Chars needed for each Special Char...! (... like Single + Double Quotes and Forward + Backslashes...), as you end up using some JS at some 3rd Level of embedded JS, while you are already in some pure JS Runtime Environment... :shock: )
- (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