add text from web page to a variable and convert it to int

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
Ha3li
Posts: 8
Joined: Mon Mar 19, 2018 3:19 pm

add text from web page to a variable and convert it to int

Post by Ha3li » Mon Mar 19, 2018 3:36 pm

Hello guys,
I want to add a text from a web page to a variable and convert it to integer value.
EX.
I have a web page and there is a text in that page like (Hello i am 20 years old.)
And this is the html code with class <b class="hello">Hello i am 20 years old.</b>
Now i want to take "20" to a variable and covert it to integer to add this number to another integer variable.
Any help?!!
chivracq
Posts: 8198
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: add text from web page to a variable and convert it to i

Post by chivracq » Mon Mar 19, 2018 4:57 pm

Ha3li wrote:Hello guys,
I want to add a text from a web page to a variable and convert it to integer value.
EX.
I have a web page and there is a text in that page like (Hello i am 20 years old.)
And this is the html code with class <b class="hello">Hello i am 20 years old.</b>
Now i want to take "20" to a variable and covert it to integer to add this number to another integer variable.
Any help?!!
CIM...! :mrgreen: (Read my Sig...)

Well, use 'EXTRACT' to extract your Field and 'EVAL()' to isolate the "20" from the Extract and to do your Data Manipulation... :idea:
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
Ha3li
Posts: 8
Joined: Mon Mar 19, 2018 3:19 pm

Re: add text from web page to a variable and convert it to i

Post by Ha3li » Mon Mar 19, 2018 6:00 pm

chivracq wrote:
Ha3li wrote:Hello guys,
I want to add a text from a web page to a variable and convert it to integer value.
EX.
I have a web page and there is a text in that page like (Hello i am 20 years old.)
And this is the html code with class <b class="hello">Hello i am 20 years old.</b>
Now i want to take "20" to a variable and covert it to integer to add this number to another integer variable.
Any help?!!
CIM...! :mrgreen: (Read my Sig...)

Well, use 'EXTRACT' to extract your Field and 'EVAL()' to isolate the "20" from the Extract and to do your Data Manipulation... :idea:
Thanks, but what if "20" is dynamic not static (changes every time i refresh the page)
i.e. next time the text will be (Hello i am 23 years old.) and so on.
chivracq
Posts: 8198
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: add text from web page to a variable and convert it to i

Post by chivracq » Mon Mar 19, 2018 6:07 pm

Ha3li wrote:Thanks, but what if "20" is dynamic not static (changes every time i refresh the page)
i.e. next time the text will be (Hello i am 23 years old.) and so on.
You missed the "CIM" part... :roll:
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
Posts: 8198
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: add text from web page to a variable and convert it to i

Post by chivracq » Thu Mar 22, 2018 9:33 pm

And..., any Follow-up/Progress...? :?:
... As I see that you are checking your Thread..., you don't need 3 days to mention 3 Versions I would think...!? :shock:
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
Ha3li
Posts: 8
Joined: Mon Mar 19, 2018 3:19 pm

Re: add text from web page to a variable and convert it to i

Post by Ha3li » Thu Mar 22, 2018 9:39 pm

chivracq wrote:And..., any Follow-up/Progress...? :?:
... As I see that you are checking your Thread..., you don't need 3 days to mention 3 Versions I would think...!? :shock:
Yup, i get it

Code: Select all

SET !EXTRACT_TEST_POPUP NO
TAG POS=1 TYPE=b ATTR=CLASS:hello EXTRACT=TXT

SET !VAR1 EVAL("var s=\"{{!EXTRACT}}\"; s.split(' ')[3];")
SET !VAR1 EVAL("parseInt({{!var1}})")
Thanks for u bro :D
chivracq
Posts: 8198
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: add text from web page to a variable and convert it to i

Post by chivracq » Thu Mar 22, 2018 9:56 pm

Ha3li wrote:
chivracq wrote:And..., any Follow-up/Progress...? :?:
... As I see that you are checking your Thread..., you don't need 3 days to mention 3 Versions I would think...!? :shock:
Yup, i get it

Code: Select all

SET !EXTRACT_TEST_POPUP NO
TAG POS=1 TYPE=b ATTR=CLASS:hello EXTRACT=TXT

SET !VAR1 EVAL("var s=\"{{!EXTRACT}}\"; s.split(' ')[3];")
SET !VAR1 EVAL("parseInt({{!var1}})")
Thanks for u bro :D
Yep..., very-very good...! That's one very good Solution... And Thanks for sharing... :D

You didn't mention your FCI like I asked you (x2), fair enough then..., but be aware that next time you'll open a Thread, I won't even react if you don't include that Required Info in your OP, just saying... :idea:

EDIT: Hum..., and that's exactly what I mean, applied to your 2nd Thread that you just opened... :roll:

But hum..., we are not going to be "Friends" I'm afraid..., and I wouldn't answer that 2nd Thread anyway as I only help Users using the Forum "a bit correctly"..., which starts by opening your Threads in the correct Sub-Forum...! Your 2nd Thread has nothing to do with 'Data Extraction'...., grr...!
Correct Sub-Forum is the 'General' one... (You can still delete that Thread (as long as nobody posts in it after you) and open it in the correct Sub-Forum...)
+ I don't answer Threads either with ugly Typos / Spelling Mistakes in the Thread Title... :idea:
Last edited by chivracq on Thu Mar 22, 2018 10:11 pm, edited 1 time in total.
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
Ha3li
Posts: 8
Joined: Mon Mar 19, 2018 3:19 pm

Re: add text from web page to a variable and convert it to i

Post by Ha3li » Thu Mar 22, 2018 10:03 pm

chivracq wrote:
Ha3li wrote:
chivracq wrote:And..., any Follow-up/Progress...? :?:
... As I see that you are checking your Thread..., you don't need 3 days to mention 3 Versions I would think...!? :shock:
Yup, i get it

Code: Select all

SET !EXTRACT_TEST_POPUP NO
TAG POS=1 TYPE=b ATTR=CLASS:hello EXTRACT=TXT

SET !VAR1 EVAL("var s=\"{{!EXTRACT}}\"; s.split(' ')[3];")
SET !VAR1 EVAL("parseInt({{!var1}})")
Thanks for u bro :D
Yep..., very-very good...! That's one very good Solution... And Thanks for sharing... :D

You didn't mention your FCI like I asked you (x2), fair enough then..., but be aware that next time you'll open a Thread, I won't even react if you don't include that Required Info in your OP, just saying... :idea:
I am so sorry, but i am a new user here and i don't know what do you mean about these sentences
CIM...! (Read my Sig...)
You missed the "CIM" part...
You didn't mention your FCI
i am sorry again :( :(
chivracq
Posts: 8198
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: add text from web page to a variable and convert it to i

Post by chivracq » Thu Mar 22, 2018 10:15 pm

Ha3li wrote:I am so sorry, but i am a new user here and i don't know what do you mean about these sentences
CIM...! (Read my Sig...)
You missed the "CIM" part...
You didn't mention your FCI
i am sorry again :( :(
Yeah, well, "Read my Sig..." means "Read my Signature..." which explains completely "CIM"/"FCIM"/"FCI"...
Or you can read the Forum Rules like you should have done..., for Required Info to include in your OP when you start a Thread...

And hum, I edited my previous Reply in the time that you were posting your new Reply... (concerning your 2nd Thread...)
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
Ha3li
Posts: 8
Joined: Mon Mar 19, 2018 3:19 pm

Re: add text from web page to a variable and convert it to i

Post by Ha3li » Thu Mar 22, 2018 10:47 pm

chivracq wrote:
Ha3li wrote:I am so sorry, but i am a new user here and i don't know what do you mean about these sentences
CIM...! (Read my Sig...)
You missed the "CIM" part...
You didn't mention your FCI
i am sorry again :( :(
Yeah, well, "Read my Sig..." means "Read my Signature..." which explains completely "CIM"/"FCIM"/"FCI"...
Or you can read the Forum Rules like you should have done..., for Required Info to include in your OP when you start a Thread...

And hum, I edited my previous Reply in the time that you were posting your new Reply... (concerning your 2nd Thread...)
Now i know what do you mean about CIM.
I deleted my 2nd thread.
I respect that "we are not going to be "Friends" I'm afraid".
Finally i have not a lot of English, because i am a middle eastern (Egyptian) .. "I don't answer Threads either with ugly Typos / Spelling Mistakes in the Thread Title".
Thanks a lot.
Post Reply