IMACROS subtracting text from extraction - extract

I'm extracting text from a website:
TAG POS=1 TYPE=TD ATTR=TXT:*<SP>(View<SP>Listing) EXTRACT=TXT
but later i want to use only what is before the VIEW LISTING text so i want to subtract this from the EXTRACT, how to do it?
I tried this:
SET !CLIPBOARD {{!EXTRACT}}
ADD !CLIPBOARD -<SP>(View<SP>Public<SP>Listing)
and this:
SET !EXTRACT EVAL("var s=\"{{!EXTRACT}}\"; s.slice(\"'\", -22);")
(found both on stack) but none of these work. also i can't extract without this text in the first place (the site is built this way)

Okay stupid mistake in syntax, found the solution:
SET !EXTRACT EVAL("var s=\"{{!EXTRACT}}\"; s.slice(\"\", -22);")

Related

Is there a way, using Imacros for Firefox, to extract an image from within a DIV that has a certain class?

I'm not sure of the syntax within iMacros (10.0.2.1450, which has been paid for, and is being run on Firefox Quantum 66.0.3) to extract an image from within a DIV with a particular class
I have tried to look up info on the iMacros wiki and have Googled extensively, but am not sure how to extract the image, when I think the type needs to be DIV with a particular class as the Attribute.
TAG POS=1 TYPE=IMG ATTR=ALT:*&&SRC:*&&CLASS:particularclass EXTRACT=HREF
This is the code on the site I'm trying to extract the image from
<div class="particularclass">
<img alt="sample" src="https://sample.com/sample.jpg">
</div>
I'm trying to save this image. I don't want to find it on the page based on any details of the image, I want to find it on the page by finding the div with a particular class, and saving the image within that div
When I tried the following, it's not finding an image with this class:
TAG POS=1 TYPE=IMG ATTR=ALT:*&&SRC:*&&CLASS:particularclass EXTRACT=HREF
If anyone can help with the syntax, I'll be eternally grateful!
Thanks,
Paul
TAG POS=1 TYPE=DIV ATTR=CLASS:*replaceWithATTRclass*EXTRACT=*replaceWithATTRname*
Try this code, replace replaceWithATTRname with the name of the ATTR you want to extract, and replace replaceWithATTRclass with your class. You can also change the Type accordingly along with the position.

Copy/Paste through tabs on Chrome with iMacros?

'part 1 - copy session
SET !EXTRACT_TEST_POPUP NO
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:product-form ATTR=ID:Name EXTRACT=TXT
SET !VAR1 EVAL("\"{{!EXTRACT}}\".replace(/a'/g, \"à\") .replace(/e'/g, \"è\") .replace(/i'/g, \"ì\") .replace(/o'/g, \"ò\") .replace(/u'/g, \"ù\") .replace(/A'/g, \"À\") .replace(/E'/g, \"È\") .replace(/I'/g, \"Ì\") .replace(/O'/g, \"Ò\") .replace(/U'/g, \"Ù\")")
SET !EXTRACT NULL
TAG POS=1 TYPE=A ATTR=TXT:EN
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:product-form ATTR=ID:Locales_1__Name EXTRACT=TXT
SET !VAR2 {{!EXTRACT}}
SET !EXTRACT NULL
WAIT SECONDS=2.0
'part 2 - paste session
TAG POS=1 TYPE=A ATTR=TXT:IT
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:product-form ATTR=ID:Locales_0__Name CONTENT={{!VAR1}}
etc
etc
etc
This is the first part of code I used until now.
Now I need to copy my source text from another tab of chrome in order to make this one the {{!VAR1}} which will be pasted all over the textboxes in another tab.
TAB T=1
FRAME F=2
TAG POS=1 TYPE=DIV ATTR=CLASS:MagicZoomHeader EXTRACT=TXT
SET !VAR1 EVAL("\"{{!EXTRACT}}\".replace(/a'/g, \"à\") .replace(/e'/g, \"è\") .replace(/i'/g, \"ì\") .replace(/o'/g, \"ò\") .replace(/u'/g, \"ù\") .replace(/A'/g, \"À\") .replace(/E'/g, \"È\") .replace(/I'/g, \"Ì\") .replace(/O'/g, \"Ò\") .replace(/U'/g, \"Ù\")")
SET !EXTRACT NULL
TAB T=2
This is the code which extract the text I need from TAB 1.
In order to do this, I write the code using TAB T=1 (to copy and create the first VAR) and TAB T=2 in order to paste the text.
When the macro goes to TAB 2 (starting part 2), suddenly stopped working doing a sort of infinite loading before process this
TAG POS=1 TYPE=A ATTR=TXT:IT
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:product-form ATTR=ID:Locales_0__Name CONTENT={{!VAR1}}
Why this happens? How can I resolve that?

How to click link with changing attributes using imacros?

I am creating a macro in which I want to click the anchor element.
The problem with this anchor element is that all the attributes changes randomly after every click.
Below is the anchor link
<a id="bLMa" class="**btn valign-wrapper** pulse **animated** lime accent-2 black-text">**Stаrt**</a>
Items marked between star always remain same. All other items changes continuously.
The location of the anchor changes randomly after every click.
I tried below steps
TAG XPATH="//*[#class="animated"]"
TAG POS=1 TYPE=A ATTR=Class:animated
TAG POS=1 TYPE=A ATTR=TXT:Start
TAG POS=1 TYPE=A ATTR=TXT:*Start*
I always get the same error as Element Not Found.
Please suggest.
You can try combining Attributes to identify the anchor you want to find as per http://wiki.imacros.net/TAG_parameters_explained#Multiple_ATTR_parameters
For your specific example something like
TAG POS=1 TYPE=A ATTR=class:*animated*&&TXT:*Start*
could work, looking for the class animated AND the text Start together in an anchor.

iMacro Help: ATTR ID for checkbox keep changing and asterisks not work

As title, I am trying to click the clickbox automatically using Chrome iMacros. However the ATTR id for the checkbox keep changing. I found that replace the id with asterisk * should work, however, I got no luck using the asterisk, so anyone know if there are any other solution? Here is the sample iMacros:
Direct capture using iMacros record:
TAG POS=1 TYPE=INPUT:CHECKBOX ATTR=ID:gwt-uid-7116 CONTENT=YES
Replace asterisks(*):
TAG POS=1 TYPE=INPUT:CHECKBOX ATTR=ID:gwt-uid-* CONTENT=YES

How to extract specific text with imacros xpath

I have this code in a website:
<div id="1234">
<li>
text I want to extract
<span>
text I don't want to extract
</span>
</li>
</div>
I'm using this IMACROS code, but it extracts both texts:
TAG XPATH="id('1234')/li[1]" EXTRACT=TXT
I was trying to use text() at the end but get an error.
For your Specific case Shugar's code with some tweaking will work. Split \n and extract [1] :
TAG XPATH="id('1234')/li[1]" EXTRACT=TXT
SET !EXTRACT EVAL("'{{!EXTRACT}}'.split('\\n')[1];")
PROMPT {{!EXTRACT}}
If you want a more General approach you can get li[1] and split by content of span at [0]:
TAG XPATH="id('1234')/li[1]" EXTRACT=TXT
SET !VAR1 {{!EXTRACT}}
SET !EXTRACT NULL
TAG XPATH="id('1234')/li[1]/span" EXTRACT=TXT
SET !EXTRACT EVAL("'{{!VAR1}}'.split('{{!EXTRACT}}')[0];")
PROMPT {{!EXTRACT}}
I suggest just adding one more line in your code:
TAG XPATH="id('1234')/li[1]" EXTRACT=TXT
SET !EXTRACT EVAL("'{{!EXTRACT}}'.split('<span>')[0];")