Doing Standard Math Calculations - NOT CAPTCHA RELATED

genetrader

Client
Регистрация
31.03.2011
Сообщения
26
Благодарностей
0
Баллы
1
Newbie question here... I am trying to divide 1 variable by another or a fixed number.. for example, I am using the Take DOM command to scrape the total number of results off of a page and put that # into a variable called ResultCount. I then know that there are 25 results per page, so I want to create a counter from ResultCount by dividing ResultCount by 25 and looping the pages to scrape by the rounded up results # (for example there are 140 results so 140 / 25 = 5.6 rounded up to 6. So we need to run the scraper for 6 loops...

I am having difficulty how or where standard mathematic calculations are done ... such as resolving simple X - Y, X + Y, X / Y, and X * Y when working with scraped values... Is there a different way to treat text or numeric variables as I have not seen where this would be controlled...

Im sorry but I have searched all videos and this forum for these simple calculation answers and cant find. I great appreciate any and all help provided! Thanks

All the best,

Gene
 

rostonix

Известная личность
Регистрация
23.12.2011
Сообщения
29 067
Благодарностей
5 705
Баллы
113


And you can put in Javascript code:

{-Variable.one}+{-Variable.two-}
{-Variable.one}-{-Variable.two-}
{-Variable.one}*{-Variable.two-}
{-Variable.one}/{-Variable.two-}
 

genetrader

Client
Регистрация
31.03.2011
Сообщения
26
Благодарностей
0
Баллы
1
THANKS FOR THE PROMPT RESPONSE!! Now - I am scraping a number that is in TEXT on the page that says "141 Results". I am able to get the # and put it to a variable but when I used your JS formula layout it didnt work. Do I somehow need to format the variable to tell it that it is numeric? I am using DOM... should I use a different element to GET DATA?
 

rostonix

Известная личность
Регистрация
23.12.2011
Сообщения
29 067
Благодарностей
5 705
Баллы
113
You can operate that kind of calculations only if you have numbers in your variables.

So make sure you scrape data and prepare it with regex so you will have only numbers to use )
 

genetrader

Client
Регистрация
31.03.2011
Сообщения
26
Благодарностей
0
Баллы
1
DISREGARD - I had accidentally modified my REGEX! THIS WORK - THANKS Rostonix!

One more question - how do I get the value to ROUND UP? It comes out 5.64... Thanks!
 

rostonix

Известная личность
Регистрация
23.12.2011
Сообщения
29 067
Благодарностей
5 705
Баллы
113
Math.round({-Variable.yourvariable-})
 

jcknick

Client
Регистрация
10.05.2013
Сообщения
154
Благодарностей
9
Баллы
18
Awesome! :-))) Where can I learn about built in math functions?
 

rostonix

Известная личность
Регистрация
23.12.2011
Сообщения
29 067
Благодарностей
5 705
Баллы
113
it's javascript action
you can paste any js code there
 

jcknick

Client
Регистрация
10.05.2013
Сообщения
154
Благодарностей
9
Баллы
18
Ok, i'll look into js math functions. But a quick question regarding rounding up variables, how do I round up e.g. this value 5.678938 to this 5.68?
 

LexxWork

Client
Регистрация
31.10.2013
Сообщения
1 190
Благодарностей
785
Баллы
113
5.678938.toFixed(2);
 

jcknick

Client
Регистрация
10.05.2013
Сообщения
154
Благодарностей
9
Баллы
18
Thank you LexxWork
 

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)