Save a part of text extracted

Discussions and Tech Support related to website data extraction, screen scraping and data mining using iMacros.
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
provoquestosito
Posts: 78
Joined: Sat Jan 30, 2010 12:43 am

Save a part of text extracted

Post by provoquestosito » Sat Aug 15, 2020 2:45 am

Hi forum

Firefox 56
Imacro 8.9.7
Windows 7 at 64 bit

I extracted a text with this tag

TAG POS=1 TYPE=H5 ATTR=TXT:Must<SP>play<SP>for<SP>0:00/*<SP>minutes EXTRACT=TXT

It save in EXTRACT

Must play for 0:00/2:00<SP>minutes

or

Must play for 0:00/2:50<SP>minutes

or

Must play for 0:00/3:30<SP>minutes

Now i need a solution to save only 2:00 or 2:50 or 3:30

What EVAL i must use for this ?

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

Re: Save a part of text extracted

Post by chivracq » Sat Aug 15, 2020 1:38 pm

provoquestosito wrote:
Sat Aug 15, 2020 2:45 am
Hi forum

Code: Select all

Firefox 56
Imacro 8.9.7
Windows 7 at 64 bit
I extracted a text with this tag

Code: Select all

TAG POS=1 TYPE=H5 ATTR=TXT:Must<SP>play<SP>for<SP>0:00/*<SP>minutes EXTRACT=TXT
It save in EXTRACT

Code: Select all

Must play for 0:00/2:00<SP>minutes
or

Code: Select all

Must play for 0:00/2:50<SP>minutes
or

Code: Select all

Must play for 0:00/3:30<SP>minutes
Now i need a solution to save only 2:00 or 2:50 or 3:30

What EVAL i must use for this ?

Thanks

Rhooo...!, come on...!! :o
You've been using iMacros (correct Spelling btw, you still manage to squeeze 3 Typos in it, grrr...! :shock: ) for 10 Years now and you can't find a Solution by yourself...!? This is pretty trivial Functionality that you want... :shock:

There are probably more than 10 Solutions... OK, what have you tried...?
(I will still help you if you "really" get stuck, but this is very easy...)

Can be done with 'replace()', 'match()', 'search()', 'indexOf()', lastIndexOf()', 'substr()', 'substring()', 'split()'..., and I probably still miss a few...

'match()' and 'search()' will require some 'REGEXP', that I don't "like" myself...
The "Beginners" Solution is using 'replace()', I would go for 'split()' myself, and I have already posted that Solution dozens of times on the Forum...
But hum, the Sols with 'substr[ing]()' are also pretty simple in this Case, Standalone or combined with '[last]IndexOf()'...

OK, you need to find at least ONE Solution by yourself, ah-ah...! Then we can have a "funny Game" in this Thread and post as many different Solutions as possible, ah-ah...! :twisted:
- (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...
provoquestosito
Posts: 78
Joined: Sat Jan 30, 2010 12:43 am

Re: Save a part of text extracted

Post by provoquestosito » Sat Aug 15, 2020 11:29 pm

Thanks i used EVAL with split but need 2 commands, but works

Code: Select all

SET !EXTRACT EVAL ("var s='{{!EXTRACT}}'; s=s.split('/'); s[1];")
SET !EXTRACT EVAL ("var s='{{!EXTRACT}}'; s=s.split(' '); s[0];")

Thanks for suggestion.
chivracq
Posts: 9430
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Save a part of text extracted

Post by chivracq » Sat Aug 15, 2020 11:44 pm

provoquestosito wrote:
Sat Aug 15, 2020 11:29 pm
Thanks i used EVAL with split but need 2 commands, but works

Code: Select all

SET !EXTRACT EVAL ("var s='{{!EXTRACT}}'; s=s.split('/'); s[1];")
SET !EXTRACT EVAL ("var s='{{!EXTRACT}}'; s=s.split(' '); s[0];")

Thanks for suggestion.

Rhooo...!, very good...! You see you can do it, ah-ah...! :D :wink:

Your Sol is exactly the one I meant "with 'split()'", and you can combine several JS Statements in one same 'EVAL()' Statement..., and I consider it "Bad Practice" to morph a same Var... It might look more "simplified" and compact, but if you need to debug that/those Var(s) (using 'PROMPT'), you can only see/follow the last one...

This would be my Sol using 'split()'...:

Code: Select all

SET Play_Time EVAL ("var s='{{!EXTRACT}}'; var x,y,z; x=s.split('/'); y=x[1].split(' '); z=y[0]; z;")
PROMPT EXTRACT:<SP>_{{!EXTRACT}}_<BR>Play_Time:<SP>_{{Play_Time}}_
>>>

And now if you want to play the "Funny Game", I'm pretty sure you can manage to find another 4 other Sols...!? :P
- (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...
provoquestosito
Posts: 78
Joined: Sat Jan 30, 2010 12:43 am

Re: Save a part of text extracted

Post by provoquestosito » Wed Aug 19, 2020 12:49 am

@chivracq

You are an expert of imacros, I use few times imacros because i need automation in modern browser (Chrome and Firefox latest version) and now I switched to ui vision and the commands are different.

Now it is easier for me to write a macro with ui vision selenium than with imacros that I rarely use and some things I'm forgetting not using it more often.

I found it very difficult with imacros due to the lack of the IF command and the inability to run automatic loops in iim macros (the loop only in javascript can be set).

I love imacros because I started the first automations with imacros and I am very sorry that it has gone so bad in recent years, so much so that it is almost abandoned in favor of ui vision and katalon that have modernized and today perform all the commands of imacros more numerous others.

It is a real sadness that the new imacros requires mandatory license and that it is rarely updated, it looks like an abandoned project, while ui vision every month is updated with new features.

Some sites I use are not compatible with old browsers to use imacros (such as firefox Gecko 56 or ESR 52) so to automate everything you need software to integrate with the new modern browsers.

I am fond of this forum but unable to use full imacros in modern browsers (the personal version is very limited and requires paid license and I read a lot of negative feedback) forced me to have to replace imacros with other software suitable for updated browsers.
Post Reply