Viktor
Viktor

Reputation: 722

Imacros saving extracted txt so csv file and adding new line for each word

I have a task to extract txt from website to csv file and save info in 1 line, here is my code

Problem seems is because i'm using at the end of extract=txt\n, how i can make it in one line and keep same syntax as i'm using.

   for(var i = 1; i <= 6; i++) {
    iimPlay("CODE:"
        + 'SET !EXTRACT_TEST_POPUP NO\n'
        + 'TAG POS='+i+' TYPE=DIV ATTR=CLASS:"divtd textcenter vam" EXTRACT=TXT\n'
        + 'SAVEAS TYPE=EXTRACT FOLDER=* FILE=trafficgoals.csv\n'
        );
    }

Upvotes: 0

Views: 1290

Answers (1)

Shugar
Shugar

Reputation: 5299

Try in the following way:

var M = "";
for (i = 1; i <= 6; i++)
    M += 'TAG POS=' + i + ' TYPE=DIV ATTR=CLASS:"divtd textcenter vam" EXTRACT=TXT\n';
M += 'SET !EXTRACT EVAL("\'{{!EXTRACT}}\'.replace(/\\\\n/g, \'\');")\n'; 
M += 'SAVEAS TYPE=EXTRACT FOLDER=* FILE=trafficgoals.csv\n';
iimPlayCode(M);

Upvotes: 1

Related Questions