Extract data from TABLE "TAG code it's frozen"

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
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
sebaa
Posts: 21
Joined: Fri Sep 13, 2019 11:49 pm

Extract data from TABLE "TAG code it's frozen"

Post by sebaa » Tue Oct 08, 2019 10:51 pm

Hi and Thank you very much for taking the time to read and respond to this post!


I was trying to extract information from an HTML table, I researched well in the wiki and other posts but I still can't make it work.

iMacros is "locked - frozen" in the first line TAG, try with variants of the code, with other cells and even with other web pages but it does not work.

I want to extract information from an HTML created by this forum, the code is here below and its respective link.

I tried many ways and read on several sides but still nothing of what I do works, everything is the same.


EDIT:
ErroriMacros.png
My code... EDIT: SET !VAR1

Code: Select all

VERSION BUILD=1005 RECORDER=CR
SET !ERRORIGNORE YES
SET !EXTRACT_TEST_POPUP NO
SET !TIMEOUT_STEP 3

TAG POS=1 TYPE=TD ATTR=ID:cell_1-1 EXTRACT=TXT
SET !VAR1 {{!EXTRACT}}
SET !EXTRACT NULL

Code: Select all

<html>

<head>
    <style>
        .table
        {
            width: 100%
        }
        .row .cell
        {
            padding: 5px;            
            border: 1px solid black;
        }
        
    </style>
    <script>
        window.onload = function () {
            var datasource = document.getElementById('datasource');
            datasource.addEventListener('change', function (e) {
                var csvFile = datasource.files[0];
                var fileReader = new FileReader();
                fileReader.onloadend = function (e) {
                    var table = document.getElementById('table');
                    var lines = fileReader.result.split(/\r?\n/);
                    var n = 0;
                    lines.forEach(function (line) {
                        n++;
                        var tr = document.createElement("tr");
                        tr.setAttribute("class", "row");
                        tr.setAttribute("id", "row_" + n);
                        var cells = line.split(/,/);
                        var m = 0;
                        cells.forEach(function (cell) {
                            var td = document.createElement("td");
                            m++;
                            td.setAttribute("id", "cell_" + n + "-" + m);
                            td.setAttribute("class", "cell");
                            var text = document.createTextNode(cell);
                            td.appendChild(text);
                            tr.appendChild(td);
                        });
                        table.appendChild(tr);
                    });
                }
                fileReader.readAsText(csvFile);
            }, false);
        }
    </script>
</head>

<body>
    Select CSV file:
    <input type="file" id="datasource" />
    <div>Table with loaded CSV file:</div>
    <table id="table" class=table></table>
</body>

</html>
Link to this HTML code for Load .CSV ---> viewtopic.php?f=21&t=28245
  • Windows 10 x64
    Chrome: v77
    iMacros: 10.0.5 'Free'
Last edited by sebaa on Wed Oct 09, 2019 2:43 am, edited 4 times in total.
chivracq
Posts: 9766
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Extract data from TABLE "TAG code it's frozen"

Post by chivracq » Tue Oct 08, 2019 11:51 pm

sebaa wrote:
Tue Oct 08, 2019 10:51 pm
Hi my friend! and Thank you very much for taking the time to read and respond to this post!


I was trying to extract information from an HTML table, I researched well in the wiki and other posts but I still can't make it work.

iMacros is "locked - frozen" in the first line TAG, try with variants of the code, with other cells and even with other web pages but it does not work.

I want to extract information from an HTML created by this forum, the code is here below and its respective link.

I tried many ways and read on several sides but still nothing of what I do works, everything is the same.


Link img: https://ibb.co/yWXmWXv i can't see the image in preview, maybe because i use chrome... i don't know
Image

My code...

Code: Select all

VERSION BUILD=1005 RECORDER=CR
SET !ERRORIGNORE YES
SET !EXTRACT_TEST_POPUP NO
SET !TIMEOUT_STEP 3

TAG POS=1 TYPE=TD ATTR=ID:cell_1-1 EXTRACT=TXT
SET !VAR {{!EXTRACT}}
SET !EXTRACT NULL

Code: Select all

<html>

<head>
    <style>
        .table
        {
            width: 100%
        }
        .row .cell
        {
            padding: 5px;            
            border: 1px solid black;
        }
        
    </style>
    <script>
        window.onload = function () {
            var datasource = document.getElementById('datasource');
            datasource.addEventListener('change', function (e) {
                var csvFile = datasource.files[0];
                var fileReader = new FileReader();
                fileReader.onloadend = function (e) {
                    var table = document.getElementById('table');
                    var lines = fileReader.result.split(/\r?\n/);
                    var n = 0;
                    lines.forEach(function (line) {
                        n++;
                        var tr = document.createElement("tr");
                        tr.setAttribute("class", "row");
                        tr.setAttribute("id", "row_" + n);
                        var cells = line.split(/,/);
                        var m = 0;
                        cells.forEach(function (cell) {
                            var td = document.createElement("td");
                            m++;
                            td.setAttribute("id", "cell_" + n + "-" + m);
                            td.setAttribute("class", "cell");
                            var text = document.createTextNode(cell);
                            td.appendChild(text);
                            tr.appendChild(td);
                        });
                        table.appendChild(tr);
                    });
                }
                fileReader.readAsText(csvFile);
            }, false);
        }
    </script>
</head>

<body>
    Select CSV file:
    <input type="file" id="datasource" />
    <div>Table with loaded CSV file:</div>
    <table id="table" class=table></table>
</body>

</html>
Link to this HTML code for Load .CSV ---> viewtopic.php?f=21&t=28245
  • Windows 10 x64
    Chrome: v77
    iMacros: 10.0.5

Code: Select all

Windows 10 x64
Chrome: v77
iMacros: 10.0.5
FCI mentioned, good, but 'Free'/'PE' is missing for me to have a look... :(
(That's the first (and nearly only) bit of Info I check in a Post/Thread before deciding if I will read it... If anything is missing, I don't read..., or certainly don't answer...)

You have a Dedicated Sub-Forum about 'Data-Extraction' where this Thread should have been opened... (But no need to duplicate now...)
The 'General' Sub-Forum is always OK if you "hesitate", but this one is clearly about "Extraction" I would think, without reading it (yet)..., from your Thread Title...

(Your "my Friend" is a bit "annoying" btw, I guess it's meant for me, but I'm not the only (Advanced) User answering Threads on the Forum... :x )

Oh...!, and I guess I'll have to check SOF, you've probably also opened a parallel Thread on that Forum..., to check that you've provided the same "Quality" as here... (Alright, that might wait until tomorrow then, it can take a few hours before I get the Notifs... :| )
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
sebaa
Posts: 21
Joined: Fri Sep 13, 2019 11:49 pm

Re: Extract data from TABLE "TAG code it's frozen"

Post by sebaa » Wed Oct 09, 2019 12:28 am

Hi again chivracq!


I will not post more on "SOF" since you told me that it is practically not ideal, therefore I will only post here.

I did not read the subforum of which you told me but look for information in other ways, even so the code is basic and compare it with others but it still does not work ...

----

What could be the cause of this "error"?
chivracq
Posts: 9766
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Extract data from TABLE "TAG code it's frozen"

Post by chivracq » Wed Oct 09, 2019 1:49 am

sebaa wrote:
Wed Oct 09, 2019 12:28 am
Hi again chivracq!

I will not post more on "SOF" since you told me that it is practically not ideal, therefore I will only post here.

I did not read the subforum of which you told me but look for information in other ways, even so the code is basic and compare it with others but it still does not work ...

----

What could be the cause of this "error"?

OK, FCI mentioned:

Code: Select all

Windows 10 x64
Chrome: v77
iMacros: 10.0.5 'Free'
>

You've removed the "my Friend", I see..., was more for "a next time", but OK, good... :|

>

Well, about the 'Data-Extraction' Sub-Forum, I'm not asking you to "read it", (well, it's always a "useful Occupation' though, ah-ah...!), but you should have opened this current Thread in that Forum... Several (Advanced) Users, including me and even @TechSup have subscribed to (only) specific Sub-Forums based on our "Expertise", and it's "annoying" when we get a "false" Notif about a New Thread which has nothing to do with our Expertise, or on the contrary, you will be missing some Advanced Users to look at your Thread because you didn't post in the "correct" Sub-Forum... :idea:
Same Mechanism/Principle like on SOF with the different Tags they use, like the ''iMacros' Tag... :wink:

And on our Forum, Users also search the Forum and review/read some Threads that have already been classified together in a same Sub-Forum... 8)

>

And well, about SOF, tja..., like I told you, there is not much Expertise about iMacros there... And I find that Forum usually not very "suitable" for iMacros Qt's that often require a bit of back-and-forth Communication... It is mostly meant for "easy" Qt's with one "straightforward" Answer... But all those "easy" Qt's have already been asked and answered dozens of time on our Forum... So when sbd manages to ask "such an easy Qt" on SOF, that only means they didn't read any Documentation nor search the (= our) Forum... :shock:

A few Exceptions maybe:
If your Qt is pretty "Advanced" about "pure" JavaScript, then yep, there is much more Expertise about JS on SOF, and also about "pure" 'XPATH' and 'REGEXP', but I think that's about it...
And about 'XPATH' and 'REGEX', that "because" I never dug into it as I find it a bit "too complicated" for what is usually needed with iMacros, and there are much easier Alternatives, so I never use those 2...

>

Ah OK, yep, I know that Thread from @Marcia from TechSup, good that you found it yourself, that was one of the "Alternatives" I had mentioned...
Even if, hum, I think she's modified that '.html' Page since she had first posted it, I don't remember there was some Mechanism to input/read directly from a Local '.CSV' File in it... Hum..., interesting...! I still find it a bit cumbersome, is my first Reaction, but OK, I'll need to have a look at it... 8)

>

A bit late already for me now, I'll have a look tomorrow...

But hum, I see some other "Show-Stopper" for me to answer your Thread, you've uploaded some Printscreen on some external Pix Server. Oops!, not good for me!, you need to upload your Printscreen directly to the Forum... :!:

Consider spending 1 Min to read the Forum Rules, everything I "complained about" is mentioned in the Forum Rules (hum, except the "my Friend", ah-ah...!), that would speed up "the Process"... :idea:

(And you have a Typo in your Script, from a quick Look... :wink: )
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
chivracq
Posts: 9766
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Extract data from TABLE "TAG code it's frozen"

Post by chivracq » Wed Oct 09, 2019 1:42 pm

Ah OK, I see you've edited your OP to upload your Screenshot directly to the Forum... Hum, and the "Quality" of that Screenshot is "surprisingly" much better also I notice, compared with the one you had previously... I could hardly read your Script and I wasn't sure about the "!VAR" or "!VAR1" on the Screenshot, but you had "luckily" also posted your Script in clear Text..

And then, OK, you've found "the Typo", and editing your Script from:

Code: Select all

SET !TIMEOUT_STEP 3

TAG POS=1 TYPE=TD ATTR=ID:cell_1-1 EXTRACT=TXT
SET !VAR {{!EXTRACT}}
... to:

Code: Select all

SET !TIMEOUT_STEP 3

TAG POS=1 TYPE=TD ATTR=ID:cell_1-1 EXTRACT=TXT
SET !VAR1 {{!EXTRACT}}
... (=> "!VAR" => "!VAR1"), isn't it already the Reason why your Script was hanging on the 'TAG' Line because of that next Line with a '!VAR' that does not exist and that the Runtime Engine apparently doesn't know what to do about...?

(Even if it should abort and throw an Error instead of hanging, or simply ignore that Line as you are using '!ERRORIGNORE'... So, we would have a mini-Bug here anyway, I would think...)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
sebaa
Posts: 21
Joined: Fri Sep 13, 2019 11:49 pm

Re: Extract data from TABLE "TAG code it's frozen"

Post by sebaa » Wed Oct 09, 2019 2:58 pm

Good morning!

I was trying in several ways, delete those commands and leave only the TAG line, even so it remains unresolved.

Try trying to extract "ID", "CLASS" and both but there is no case ... continue with the same problem without continuing.

Try variants of the code but it remains unresolved.

I don't understand why this happens.

Can you think of an alternative because it happens?

Could you try 3 minutes to execute the code and create an example .CSV as I did? I'm lost now, I can't think of anything

I would like to extract by row, first select the row and then extract the information of COL1 and then that of COL 2. Then jump to the next row and repeat the extraction of COL 1 and COL 2

Thanks you!
chivracq
Posts: 9766
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Extract data from TABLE "TAG code it's frozen"

Post by chivracq » Wed Oct 09, 2019 11:00 pm

sebaa wrote:
Wed Oct 09, 2019 2:58 pm
Good morning!

I was trying in several ways, delete those commands and leave only the TAG line, even so it remains unresolved.

Try trying to extract "ID", "CLASS" and both but there is no case ... continue with the same problem without continuing.

Try variants of the code but it remains unresolved.

I don't understand why this happens.

Can you think of an alternative because it happens?

Could you try 3 minutes to execute the code and create an example .CSV as I did? I'm lost now, I can't think of anything

I would like to extract by row, first select the row and then extract the information of COL1 and then that of COL 2. Then jump to the next row and repeat the extraction of COL 1 and COL 2

Thanks you!

OK, I don't know as I don't use this 'Free' Version for CR (and I hate this stupid Browser also, (People, wake up...!!!!), I only launch it once a month for Forum Cases, but I already launched it x2 this month, you only have 21 days to wait till my "next Round", ah-ah...!)
Had a Friend visiting unexpectedly tonight, well, I'm "Social", so "they" all know that, and pfff, would need to do some Testing myself, which I think will take a few hours..., and I don't really have the time right now, + have to DJ and prepare a bit for tomorrow and Fr., and WE is always a bit busy for me, so I guess "we" are already talking about "next Week Monday" (if I'm not too fucked up from the WE, oops...!) for me to do any Testing...

(I had some Time yesterday when you opened your Thread, pity (for you) FCI was not complete, and Screenshot was not uploaded directly on the Forum..., I didn't expect that Friend coming by today, + new perspectives/things I need to handle/prospect...).

But I suspect it "all" will work fine in my Test-Env, and that the Pb is specific to CR and iMacros v10.0.5 for CR about the Hanging Pb, there is some very recent Thread about v10.0.5 for CR + Local File opened through 'URL GOTO=file:///...' and iMacros hanging, your 2 Cases could be related...
I don't know, you'll have to wait until Fr.2019-11-01 that I launch that stupid Browser again... :|

>>>

But OK, next to the "Hanging" which I can't test until Novb 2019 as I suspect it is specific to CR and iMacros for CR...
You can try a short (=1) Setting for '!TIMEOUT_PAGE', maybe that helps...
But I suspect the 'addEventListener()' on the Local Page is "creating" the Pb, together with 'FileReader()', I don't know, I would need to do some Testing...

But if you can't wait until 2019-11-01 @OP, maybe an Idea to simply save your '.CSV' as '.htm(l)' from 'Excel' or your Spreadsheet Soft, only takes 1 Sec for the same Result... You won't get those "sexy" ID's with "1-1" / "3-2" to identify the Cells like in @Marcia's Post, but easy to workaround with 'R-POS' if you insert a Col with "Row_[1-n]" in your CSV as the 1st Col.

Same with your 'Wish" to extract the Data Row by Row...
It can be done but it's not completely straightforward, iMacros has a Mechanism to extract Data only at the whole Table Level (=> 'TYPE=TABLE') or at the Cell Level (=> 'TYPE=TD')...
Row by Row can be done, or Cells Selection also, but it's not "Built-in", a bit "Advanced" and I don't have the Time now... :wink:

But Extract by Row can also be done with a 'TYPE=TR' (or '=TH' for the Header) + 'EXTRACT=TXT' if you insert some "fake" Col with "##" for example as a Separator between each Col, to reuse in 'EVAL()' to re-separate the Data from the whole Row... (as the Data otherwise gets extracted all in just one String, stg like Row_2: "Cell_2-1Cell_2-2Cell_2-3etc...!")...
Can also be done with 'EXTRACT=HTM' but it's not easier...
Again, it can be done, but it's not straightforward, and it's not "Standard" built-in Func in iMacros... And you are pretty Newbie, so I guess you probably won't understand anything from this last Paragraph, ah-ah...! :wink:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
sebaa
Posts: 21
Joined: Fri Sep 13, 2019 11:49 pm

Re: Extract data from TABLE "TAG code it's frozen"

Post by sebaa » Thu Oct 10, 2019 2:56 am

Thanks for answering!

I understand that you are very busy with your personal life and so on!

Hopefully you can take some time to help solve this problem that is strange, I think that many users can find it valuable to know this answer!

>
Prior to this method I had tried saving the .CSV file as HTM and as HTML and as you commented there is no "good" classification so it is more complicated although I know how to use the relative position; The problem is that it does not work either, the program is "frozen" in TAG, exactly the same thing happens and I have tried in several ways that is why I am half disintegrated!

I would like it to be a simple method and to work without problems, it seems very strange that a simple table cannot be extracted ... it is rare
chivracq
Posts: 9766
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Extract data from TABLE "TAG code it's frozen"

Post by chivracq » Thu Oct 10, 2019 5:41 am

sebaa wrote:
Thu Oct 10, 2019 2:56 am
Thanks for answering!

I understand that you are very busy with your personal life and so on!

Hopefully you can take some time to help solve this problem that is strange, I think that many users can find it valuable to know this answer!

>
Prior to this method I had tried saving the .CSV file as HTM and as HTML and as you commented there is no "good" classification so it is more complicated although I know how to use the relative position; The problem is that it does not work either, the program is "frozen" in TAG, exactly the same thing happens and I have tried in several ways that is why I am half disintegrated!

I would like it to be a simple method and to work without problems, it seems very strange that a simple table cannot be extracted ... it is rare

Hum, OK, I'll do some Testing "tomorrow" after some sleep... :oops:

A bit "strange", could be related to CR77, one other very recent Thread from last week also had a Script hanging when opening a Local File from iMacros for CR v10.0.5, + CR77 (I guess)..., but the Sol/Workaround was the "!TIMEOUT_PAGE=1" that I've mentioned..., did you try it...? I guess not as you don't mention it in your Reply... :roll:

"there is no "good" classification so it is more complicated"
=> Yep there is if you follow the "Tip" I mentioned in my previous Reply about "##" as a "Col_Separator" between Cols, (but you need to understand the "Principle", then "the rest is clear and easy"... :idea: ), => and maybe for the first Col, you can use 'Row_1'/'Row_2'/'Row_3'/etc as a "Col-Header" to then use with 'R-POS' to identify your Cell in the Row... But that's if you extract the Data from your '.html'' DataSource Cell by Cell, then you don't need the "##" Separator, but you said you wanted to extract the Data Row by Row, you need to make a Decision, "my Friend"...! (Don't quote me on this one, I usually use "my Dear", or "Darling", yeah... oops...! => using "my Friend" as a "personal" Reference..., don't be too excited, hein...! :wink: )
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
sebaa
Posts: 21
Joined: Fri Sep 13, 2019 11:49 pm

Re: Extract data from TABLE "TAG code it's frozen"

Post by sebaa » Thu Oct 10, 2019 3:46 pm

good morning

I tried with that code, here I leave you a capture that I did just to show you.
iMacrosError02.PNG
Thank you for being able to spend a few minutes of your time reviewing this issue today!

My goal is to extract from row 1, Col 1 and Col 2 (the information I want is in col 1 and col 2)

In case you could not "accommodate" to extract only by row but it is more "sloppy"


I'm going to investigate a little about what you told me the "##" is there any post about this? How could I search the wiki to study it?

Thank you!
sebaa
Posts: 21
Joined: Fri Sep 13, 2019 11:49 pm

Re: Extract data from TABLE "TAG code it's frozen"

Post by sebaa » Thu Oct 10, 2019 8:05 pm

WORKS!

Solution: Unninstal 10.0.5 and Install 10.0.2 :)

>
Incompatibility with iMacros10.0.5 and CR v77! They should solve that problem ...

Bro, how can I extract the way I need?

My goal is to extract from row 1, Col 1 and Col 2 (the information I want is in col 1 and col 2)

As neat as possible, the result of the extraction was "Info 1; Data 1"

I need to get "info 1" only and later "Data 1" then go to the next row and repeat, can you advise me a little?
chivracq
Posts: 9766
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Extract data from TABLE "TAG code it's frozen"

Post by chivracq » Thu Oct 10, 2019 8:47 pm

sebaa wrote:
Thu Oct 10, 2019 3:46 pm
good morning

I tried with that code, here I leave you a capture that I did just to show you.

iMacrosError02.PNG

Thank you for being able to spend a few minutes of your time reviewing this issue today!

My goal is to extract from row 1, Col 1 and Col 2 (the information I want is in col 1 and col 2)

In case you could not "accommodate" to extract only by row but it is more "sloppy"

I'm going to investigate a little about what you told me the "##" is there any post about this? How could I search the wiki to study it?

Thank you!

Yeah, OK, but the Script I see from your Screenshot only contains '!TIMEOUT_PAGE=1', you also need '!ERRORIGNORE'...
Activating '!ERRORIGNORE' is btw always the first "Thing" you can try when getting an Error you don't "really" expect or that you want to bypass or if your Script "hangs"...

>

About "##", the Principle is "simple"..:
You will get your Data from your 'CSV' in the '.html' Form as:

Code: Select all

Info 1; ##; Data 1
Info 2; ##; Data 2
Then an 'EXTRACT' on the Row will give:

Code: Select all

TAG POS=1 TYPE=TR ATR=TXT:* EXTRACT=TXT
=> Content of the 'EXTRACT', I would think...:

Code: Select all

Info 1;##;Data 1
... And to get "Info 1" in '!VAR1' and "Data 1" in '!VAR2:

Code: Select all

SET !VAR1 EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split(';##;'); z=x[0]; z;")
SET !VAR2 EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split(';##;'); z=x[1]; z;")
PROMPT COL1_VAR1:<SP>_{{!VAR1}}_<BR>COL2_VAR2:<SP>_{{!VAR2}}_
And that extra Col with "##" is possibly not even needed as I see you already get some ";" in the Table that could already be used as the Separator for the 'split()', if your own Data won't contain any ";"...

>>>
sebaa wrote:
Thu Oct 10, 2019 8:05 pm
WORKS!

Solution: Unninstal 10.0.5 and Install 10.0.2 :)

>
Incompatibility with iMacros10.0.5 and CR v77! They should solve that problem ...

Bro, how can I extract the way I need?

My goal is to extract from row 1, Col 1 and Col 2 (the information I want is in col 1 and col 2)

As neat as possible, the result of the extraction was "Info 1; Data 1"

I need to get "info 1" only and later "Data 1" then go to the next row and repeat, can you advise me a little?

Alright, then it looks like CR77 is apparently breaking v10.0.5 for CR, if your Script doesn't hang anymore in v10.0.2 for CR... :shock:
I had "soft alerted" @TechSup a few hours earlier as they were checking the Forum and answered another Thread, for them to have a look at your Thread and test by themselves if there is a Bug involved, but they apparently haven't seen my (internal) Post yet...

You'll have to make sure that iMacros doesn't update itself automatically back to v10.0.5, and that can be a "pain in the ass" on CR, ah-ah...!

Well, now to extract your Data Cell by Cell and not Row by Row like in the first Method, if this previous Line from your Script:

Code: Select all

TAG POS=1 TYPE=TD ATTR=ID:cell_1-1 EXTRACT=TXT
SET !VAR1 {{!EXTRACT}}
... is able to extract "Info 1", if I understood correctly, then the following will extract both Cells:

Code: Select all

TAG POS=1 TYPE=TD ATTR=ID:cell_1-1 EXTRACT=TXT
SET !VAR1 {{!EXTRACT}}
'>
SET !EXTRACT NULL
TAG POS=1 TYPE=TD ATTR=ID:cell_1-2 EXTRACT=TXT
SET !VAR2 {{!EXTRACT}}

PROMPT COL1_VAR1:<SP>_{{!VAR1}}_<BR>COL2_VAR2:<SP>_{{!VAR2}}_
And if you want to loop your Script to do the same with all Rows...:

Code: Select all

TAG POS=1 TYPE=TD ATTR=ID:cell_{{!LOOP}}-1 EXTRACT=TXT
SET !VAR1 {{!EXTRACT}}
'>
SET !EXTRACT NULL
TAG POS=1 TYPE=TD ATTR=ID:cell_{{!LOOP}}-2 EXTRACT=TXT
SET !VAR2 {{!EXTRACT}}

PROMPT COL1_VAR1:<SP>_{{!VAR1}}_<BR>COL2_VAR2:<SP>_{{!VAR2}}_
And that's it... 8)

(I didn't test anything...)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
sebaa
Posts: 21
Joined: Fri Sep 13, 2019 11:49 pm

Re: Extract data from TABLE "TAG code it's frozen"

Post by sebaa » Sat Oct 12, 2019 3:19 am

I was very busy yesterday and today I could try everything!

>
Thank you very much for all your help and your explanation!

The first code works perfect (just modify a few small things)
It is exactly what I needed and is quite neat!

Extract Data From COL 1 and COL 2 with LOOP Rows
-->

Code: Select all

TAG POS={{!LOOP}} TYPE=TR ATTR=TXT:* EXTRACT=TXT
SET !VAR1 EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split(';'); z=x[0]; z;")
SET !VAR2 EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split(';'); z=x[1]; z;")
SET !EXTRACT NULL
iMacros and CR77 with this code. It does not work.

Code: Select all

SET !TIMEOUT_PAGE 1
SET !ERRORIGNORE YES
It is necessary to install 10.0.2 for it to work!

Thanks!
chivracq
Posts: 9766
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Extract data from TABLE "TAG code it's frozen"

Post by chivracq » Sat Oct 12, 2019 4:52 am

sebaa wrote:
Sat Oct 12, 2019 3:19 am
I was very busy yesterday and today I could try everything!

>
Thank you very much for all your help and your explanation!

The first code works perfect (just modify a few small things)
It is exactly what I needed and is quite neat!

Extract Data From COL 1 and COL 2 with LOOP Rows
-->

Code: Select all

TAG POS={{!LOOP}} TYPE=TR ATTR=TXT:* EXTRACT=TXT
SET !VAR1 EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split(';'); z=x[0]; z;")
SET !VAR2 EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split(';'); z=x[1]; z;")
SET !EXTRACT NULL
iMacros and CR77 with this code. It does not work.

Code: Select all

SET !TIMEOUT_PAGE 1
SET !ERRORIGNORE YES
It is necessary to install 10.0.2 for it to work!

Thanks!

Alright, glad it works, and very good, you understood "the Principle" as you were able to adapt my "s.split(';##;')" to "s.split(';')" as, like I mentioned, the extra Col with "##" was probably not needed thanks to the ';' that can already function as a Separator... :D
It's an "unusual" Case, you are a bit "lucky"... :wink:

The other Method would have worked also, (I think), even if it is also "unusual", @Marcia from @TechSup made it very neat, with every Cell in the Table with its own specific ID, this is not common, you normally have to use 'R-POS' to identify Cells in a Table... 8)

>>>

And we'll wait to see what @TechSup say once they have a look at this Thread about the possible Bug... :shock:
(I didn't test anything myself, so I still use "possible Bug"..., ah-ah...!)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
Tom, Tech Support
Posts: 3705
Joined: Mon May 31, 2010 4:59 pm

Re: Extract data from TABLE "TAG code it's frozen"

Post by Tom, Tech Support » Wed Oct 23, 2019 11:37 am

chivracq wrote:
Thu Oct 10, 2019 8:47 pm
Alright, then it looks like CR77 is apparently breaking v10.0.5 for CR, if your Script doesn't hang anymore in v10.0.2 for CR... :shock:
No, not necessarily.

@sebaa: Did you enable "Allow access to file URLs" in Chrome as explained here: Automate Local Web Pages (HTML Files)
Regards,

Tom, iMacros Support
Post Reply