Extracting Attribute from a 'RADIO' Element

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
Pipps
Posts: 3
Joined: Sun May 12, 2019 1:18 pm

Extracting Attribute from a 'RADIO' Element

Post by Pipps » Sun May 12, 2019 1:31 pm

VERSION BUILD=8970419 RECORDER=FX
FF 56
Win10 x64

Hi, i use imacros since 2 years, it's fantastic but I have a problem with this extraction.

I have this code

Code: Select all

<div class='MyFurniture'>
<form class="myfurniture_class" action="/us/fabric/artins.asp" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="gne534" /><input type="hidden" name="authenticitytok" /><div class='selectme'>
<p>Please choose product</p>
</div>
<ul class='styled-radio'>
<li>
<input type="radio" name="product_id" id="product_id_00358" value="00358" class="product_class" stockage="5" other_storage="3" />
<label for="product_id_00358">BES-03</label>
I need to extract the value of stockage that now is 5.
I have try without result :cry: can you help me?
Thanks
Last edited by Pipps on Mon May 13, 2019 4:48 pm, edited 2 times in total.
chivracq
Posts: 8525
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: I don't extract this strange value

Post by chivracq » Sun May 12, 2019 5:02 pm

Pipps wrote:
Sun May 12, 2019 1:31 pm
Hi, i use imacros since 2 years, it's fantastic but I have a problem with this extraction on FIREFOX 56

I have this code

Code: Select all

<div class='MyFurniture'>
<form class="myfurniture_class" action="/us/fabric/artins.asp" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="gne534" /><input type="hidden" name="authenticitytok" /><div class='selectme'>
<p>Please choose product</p>
</div>
<ul class='styled-radio'>
<li>
<input type="radio" name="product_id" id="product_id_00358" value="00358" class="product_class" stockage="5" other_storage="3" />
<label for="product_id_00358">BES-03</label>
I need to extract the value of stockage that now is 5.
I have try without result :cry: can you help me?
Thanks
Hum, Thread opened in the 'iMacros for FF' Sub-Forum, what is specific to iMacros for FF, especially if you don't mention your FCI...?
We have a full 'Data Extraction' Sub-Forum dedicated to only "extracting strange values" (where your Thread will be moved, no need to duplicate it), => If you can give a bit more Descriptive Title to your Thread...? => Stg like: "Extracting Attribute from a 'RADIO' Element." :idea:

FCIM...! :mrgreen: (Read my Sig...)
=> iMacros for FF v...?, FF56, OS...?

"I have try without result"
=> No Script, no URL posted, what have you tried...? What is the Problem...?

But from the Info you've provided, the "Principle" will be to do an 'EXTRACT=HTM' on this 'RADIO' Element or one of the Containing Elements + use 'EVAL()' to isolate and keep only the Data you want, which will be your "5". :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...
Pipps
Posts: 3
Joined: Sun May 12, 2019 1:18 pm

Re: I don't extract this strange value

Post by Pipps » Sun May 12, 2019 6:01 pm

Ohhh, I'm sorry but You have give me an idea with HTM and EVAL... Correct! Thanks :D
chivracq
Posts: 8525
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: I don't extract this strange value

Post by chivracq » Sun May 12, 2019 6:30 pm

Pipps wrote:
Sun May 12, 2019 6:01 pm
Ohhh, I'm sorry but You have give me an idea with HTM and EVAL... Correct! Thanks :D
Hum..., Okay..., but I won't try to help you "next time", if you don't improve the "Quality" of your Thread by giving it a (more) Descriptive Title + mentioning your FCI like I asked you..., :arrow: and "hopefully" sharing your final Solution/Script... :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...
Pipps
Posts: 3
Joined: Sun May 12, 2019 1:18 pm

Re: I don't extract this strange value

Post by Pipps » Mon May 13, 2019 6:49 am

Firefox 56 on Win10 x64
VERSION BUILD=8970419

My problem was to extract a part of html that with recorder was impossible to read (or very complex)
I use this:

Code: Select all

TAG POS=1 TYPE=INPUT:RADIO FORM=ACTION:/us/fabric/artins.asp ATTR=NAME:product_id EXTRACT=HTM
SET pkab EVAL("var s='{{!EXTRACT}}'; var x; x=s.split('stockage='); x[1];")
SET pkab EVAL("var s='{{pkab}}'; var x; x=s.split(' '); x[0];")
Perhaps there is a faster way (on EVAL sure) but this is also ok.

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

Re: I don't extract this strange value

Post by chivracq » Mon May 13, 2019 7:01 am

Pipps wrote:
Mon May 13, 2019 6:49 am
Firefox 56 on Win10 x64
VERSION BUILD=8970419

My problem was to extract a part of html that with recorder was impossible to read (or very complex)
I use this:

Code: Select all

TAG POS=1 TYPE=INPUT:RADIO FORM=ACTION:/us/fabric/artins.asp ATTR=NAME:product_id EXTRACT=HTM
SET pkab EVAL("var s='{{!EXTRACT}}'; var x; x=s.split('stockage='); x[1];")
SET pkab EVAL("var s='{{pkab}}'; var x; x=s.split(' '); x[0];")
Perhaps there is a faster way (on EVAL sure) but this is also ok.

Thanks chivracq
Ah...!, OK, FCI mentioned, and Solution/Script posted/shared... Good... And the Syntax is correct..., even if I tend to avoid reusing the same Var if I need to debug...
And yep, it can be shortened into one single 'EVAL()'..., that I would have posted if you had given a more Descriptive Title to your Thread, like I've already asked twice..., as probably no other Users will bother to check the Content of this Thread because of its vague Title... But OK, never mind...
- (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: 8525
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Problem to extract HTML value - FF:56 Imacros:8970419

Post by chivracq » Mon May 13, 2019 6:53 pm

Oh...!, OK, finally...! :D
Thread Title edited into:
"Problem to extract HTML value - FF:56 Imacros:8970419"

But, hum-hum, yeah..., a mini-little bit better than your original Thread Title but still not quite very Explanatory..., the one I had suggested ("Extracting Attribute from a 'RADIO' Element.") was better...
FCI doesn't belong to a Thread Title, unless your Pb is very specific to only that FCI/Version, which is not the case, (and correct Spelling is "iMacros" btw), then we are left with ""Problem to extract HTML value" which again is pretty vague as absolutely all Threads about 'Data Extraction' are always related to extracting some HTML Value or Content...

But OK, don't worry, that's good enough...! :wink:
I need to "report" the Thread anyway to get it moved by the Forum Admin (I can't do it myself) to the 'Data Extraction' Sub-Forum where it belongs (and try to open directly your Thread(s) in the "correct" Sub-Forum next time (and the 'General' one is always OK if you are unsure)), I can ask them also to edit the Title at the same time... 8)

>>>

Oh yeah..., and I had mentioned I would "simplify" your 'EVAL()' Statement... But hum, if you had searched the Forum also a bit, I've posted that Solution/Technique many-many times already...! (And that's also THE Reason why I'm "hassling" you to give a Descriptive and Precise Thread Title, for Users searching the Forum...!)

So if this one is working already...:

Code: Select all

TAG POS=1 TYPE=INPUT:RADIO FORM=ACTION:/us/fabric/artins.asp ATTR=NAME:product_id EXTRACT=HTM
SET pkab EVAL("var s='{{!EXTRACT}}'; var x; x=s.split('stockage='); x[1];")
SET pkab EVAL("var s='{{pkab}}'; var x; x=s.split(' '); x[0];")
Then this one in just one 'EVAL()' should also work, I would think:

Code: Select all

TAG POS=1 TYPE=INPUT:RADIO FORM=ACTION:/us/fabric/artins.asp ATTR=NAME:product_id EXTRACT=HTM
SET pkab EVAL("var s='{{!EXTRACT}}'; var y,z; y=s.split('stockage='); z=y[1].split(' '); z[0];")
I always use 'z' for the Return Value, and I use 'w,x,y' if I need Temp-Vars to "slowly" build the whole Expression, in this Case only 1 Temp-Var is enough ('y'), and if you need to debug the 'EVAL()' (with 'PROMPT'), you can simply temporarily change the (final) Return Value from 'z' to any of the Temp-Vars to already check that each Var returns the Result that you expect... :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...
Post Reply