Dear iOpus,
Example html code:
<select name="fruits">
<option value="1">Apple</option>
<option value="2">Banana</option>
<option value=3>Mango</option>
</select>
I can extract the text of selected item in combobox (option tag)
TAG POS=1 TYPE=SELECT FORM=* ATTR=NAME:fruits EXTRACT=TXT
But I want to extract the value of the selected item. I could not find how to do this.
Please help me.
How to extract value from option tag instead of text
Forum rules
iMacros EOL - Attention!
The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.
Thank you again for your business and support.
Sincerely,
The Progress Team
iMacros EOL - Attention!
The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.
Thank you again for your business and support.
Sincerely,
The Progress Team
-
- Posts: 22
- Joined: Sat May 07, 2011 6:12 am
Re: How to extract selected value instead of text from optio
It works for your example. With real website you might need to tweak the regexp. You should learn regular expressions if you don't know them yet.
Code: Select all
'In case this is in loop
SET !EXTRACT NULL
TAG POS=1 TYPE=SELECT FORM=* ATTR=NAME:fruits EXTRACT=TXT
SET !VAR1 {{!EXTRACT}}
SET !EXTRACT NULL
'Regexp searches for value by previously extracted text
SEARCH SOURCE=REGEXP:"<option value=\"([^\"])\">{{!VAR1}}" EXTRACT="$1"
PROMPT {{!EXTRACT}}
-
- Posts: 22
- Joined: Sat May 07, 2011 6:12 am
Re: How to extract selected value instead of text from optio
Thanks siniy.
This did the trick. Thanks a lot. But direct option to extract the value like (TAG POS=1 TYPE=SELECT FORM=* ATTR=NAME:select_name EXTRACT=VALUE) would have been better.
This did the trick. Thanks a lot. But direct option to extract the value like (TAG POS=1 TYPE=SELECT FORM=* ATTR=NAME:select_name EXTRACT=VALUE) would have been better.
-
- Posts: 3834
- Joined: Mon May 31, 2010 4:59 pm
Re: How to extract value from option tag instead of text
Very clever siniy! Thanks for posting your solution!
I have moved this thread to our "How-To's and Examples for Web Scraping" forum and linked it from the Wiki.
I have moved this thread to our "How-To's and Examples for Web Scraping" forum and linked it from the Wiki.
Regards,
Tom, iMacros Support
Tom, iMacros Support