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
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...!
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...!
, 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...!
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...
- (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...