Calculation of extracted values

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
raykay84
Posts: 9
Joined: Tue Aug 11, 2020 11:54 pm

Calculation of extracted values

Post by raykay84 » Fri Aug 14, 2020 9:25 pm

Hi i found this topic [url]viewtopic.php?f=7&t=29657[/url ]interesting and try to figure out a calucalation based macro myself.

I am using VERSION BUILD=10021450 in FF
Bowser FF 79.0
iMacros for FF
Windows 10 Professional 64-bit Operating system
Using the free version currently

Currently my code is following:

Code: Select all

VERSION BUILD=10021450
TAB T=1
TAG POS=1 TYPE=SPAN ATTR=TXT:* EXTRACT=TXT
SET !VAR1 EVAL("var s='{{!EXTRACT}}'; var z=s*1.05; z;")
PROMPT {{!VAR1}}

TAB T=2  
'URL GOTO=http://demo.imacros.net/Automate/AutoDataEntry
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:demo ATTR=ID:fname CONTENT={{!VAR1}}
What i am trying to reach is get the price of an item in step one and add +5% via the EVAL command to the price before i paste it into another field.
However something seems to be wrong with my code. It just extracts the price and does not modify nor paste it into the field. I made sure it only extracts numbers (Format: XX,XXX) and nothing else.
Any idea on this?

In another step i would also like to divide the price through a fixed number. Example would be to calculate how many items i can purchase for a fixed amount i have in my wallet. Would this worK?

Code: Select all

VERSION BUILD=10021450
TAB T=1
TAG POS=1 TYPE=SPAN ATTR=TXT:* EXTRACT=TXT
SET !VAR1 EVAL("var s='{{!EXTRACT}}'; var z=s/1000; z;")
PROMPT {{!VAR1}}

TAB T=2  
'URL GOTO=http://demo.imacros.net/Automate/AutoDataEntry
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:demo ATTR=ID:fname CONTENT={{!VAR1}}
Last edited by raykay84 on Sat Aug 15, 2020 7:44 am, edited 1 time in total.
chivracq
Posts: 9430
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Calculation of extracted values

Post by chivracq » Sat Aug 15, 2020 1:04 am

raykay84 wrote:
Fri Aug 14, 2020 9:25 pm
Hi i found this topic [url]viewtopic.php?f=7&t=29657[/url ]interesting and try to figure out a calucalation based macro myself.

I am using

Code: Select all

VERSION BUILD=10021450 in FF
Bowser FF 79.0 
iMacros for FF
Windows 10 Professional 64-bit Operating system
Currently my code is following:

Code: Select all

VERSION BUILD=10021450
TAB T=1
TAG POS=1 TYPE=SPAN ATTR=TXT:* EXTRACT=TXT
SET !VAR1 EVAL("var s='{{!EXTRACT}}'; var z=s*1.05; z;")
PROMPT {{!VAR1}}

TAB T=2  
'URL GOTO=http://demo.imacros.net/Automate/AutoDataEntry
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:demo ATTR=ID:fname CONTENT={{!VAR1}}
What i am trying to reach is get the price of an item in step one and add +5% via the EVAL command to the price before i paste it into another field.
However something seems to be wrong with my code. It just extracts the price and does not modify nor paste it into the field. I made sure it only extracts numbers (Format: XX,XXX) and nothing else.
Any idea on this?

In another step i would also like to divide the price through a fixed number. Example would be to calculate how many items i can purchase for a fixed amount i have in my wallet. Would this worK?

Code: Select all

VERSION BUILD=10021450
TAB T=1
TAG POS=1 TYPE=SPAN ATTR=TXT:* EXTRACT=TXT
SET !VAR1 EVAL("var s='{{!EXTRACT}}'; var z=s/1000; z;")
PROMPT {{!VAR1}}

TAB T=2  
'URL GOTO=http://demo.imacros.net/Automate/AutoDataEntry
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:demo ATTR=ID:fname CONTENT={{!VAR1}}

OK, good..., better to create your own Thread indeed, rather than "surfing" on the other one...

But I asked you to mention if you are using the 'Free'/'PE' Version of iMacros for FF v10.0.2, but that Info is still missing... => Can you add that to your FCI Section...?
- (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...
raykay84
Posts: 9
Joined: Tue Aug 11, 2020 11:54 pm

Re: Calculation of extracted values

Post by raykay84 » Sat Aug 15, 2020 7:45 am

Yes sry i added that info (its the free version)
chivracq
Posts: 9430
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Calculation of extracted values

Post by chivracq » Sat Aug 15, 2020 11:42 am

raykay84 wrote:
Sat Aug 15, 2020 7:45 am
Yes sry i added that info (its the free version)

OK, good... Always include that Info when you open a New Thread, precisely to avoid the "Discussion" later in a Thread like happened here in the Thread you linked to in your OP..., and where I btw give some "good" Advice on how to use 'PROMPT' to debug your Vars, which also applies to you...

=> Instead of using:

Code: Select all

PROMPT {{!VAR1}}
=> ... the following is more efficient:

Code: Select all

PROMPT EXTRACT:<SP>_{{!EXTRACT}}_<BR><BR>VAR1:<SP>_{{!VAR1}}_
This is "the Way" to use 'PROMPT' to follow and debug your Vars... :idea:
(Even if 'PROMPT' is a bit "buggy" in v10.0.x for FF/CR, I think the '<BR>' Command doesn't really work and gets replaced by '<SP>' (=> Space instead of a Line Break), which makes following several Vars look quickly a bit messy...)

=> What do you get in the 'PROMPT'...?

The Solution is fairly simple, you gave (nearly) all Info and the Explanation/Solution yourself in your OP.
I let you try to find it by yourself, or I'll give you the Solution "a bit later" if you don't come out by yourself... :wink: :idea:
- (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...
raykay84
Posts: 9
Joined: Tue Aug 11, 2020 11:54 pm

Re: Calculation of extracted values

Post by raykay84 » Sat Aug 15, 2020 9:21 pm

Thanks man but i could not solve it mysfelf. I used your prompt command but still the result is that is it extracting but not modifying or pasting the value.. help?
chivracq
Posts: 9430
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Calculation of extracted values

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

raykay84 wrote:
Sat Aug 15, 2020 9:21 pm
Thanks man but i could not solve it mysfelf. I used your prompt command but still the result is that is it extracting but not modifying or pasting the value.. help?

Yeah well, but again, what do you get in the 'PROMPT'...?
- (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...
Post Reply