Create Word of the Day from Meriam Webster

130 views
Skip to first unread message

Allistair Crompton

unread,
Nov 24, 2013, 11:26:38 AM11/24/13
to tas...@googlegroups.com
Hi there, 

i am trying to create a word of the day widget with Tasker and Zooper from the Meriam Webster website and ran into some problems. The word of the day can have one or more definitions. Following is an example with one definition: 

DEFINITION</strong></li><li><div></div></li></ul></div><p class="word_function">noun</p><div class="d"><div class="sense-block-one"><div class="scnt"><span class="ssens"><strong>:</strong> a computer-related product that has been widely advertised but has not and may never become available

This is a word of the day with two definitions

DEFINITION</strong></li><li><div></div></li></ul></div><p class="word_function">noun</p><div class="d"><div class="sblk"><div class="snum">1</div><div class="scnt"><span class="ssens"><strong>:</strong> a male salmon or sea trout during or after the spawning season</span></div></div><div class="sblk"><div class="snum">2</div><div class="scnt"><span class="ssens"><strong>:</strong> a herring or salmon cured by salting and smoking

I need tasker somehow to recognize if the word of the day has one or more definitions. This (n.xml) is what i have so far (most likely far from perfect, i just started with tasker)


n.xml

Bob Hansen

unread,
Nov 24, 2013, 11:52:21 AM11/24/13
to tas...@googlegroups.com
Willing to help, but Tte XML file is of no use to us for understanding what you are doing. Please post a Tasker description of the profile. Menu > export > Description to clipboard. Paste the clipboard contenxts into a post.

Tasker Newbie

unread,
Nov 24, 2013, 1:16:05 PM11/24/13
to tas...@googlegroups.com

Hi Bob,

MW-Wotd (15)
 A1: HTTP Get [ Server:Port:http://www.merriam-webster.com Path:word-of-the-day/2013/11/01/ Attributes: Cookies: Timeout:10 Mime Type:text/html Output File:Tasker/mw-wotd.txt ] 
 A2: Read File [ File:Tasker/mw-wotd.txt To Var:%mwwotd ] 
 A3: Variable Split [ Name:%mwwotd Splitter:main_entry_word"> Delete Base:Off ] 
 A4: Variable Split [ Name:%mwwotd2 Splitter:</strong> Delete Base:Off ] 
 A5: Zooper Widget Pro Variable [ Configuration:#Tmwword# = %mwwotd21 Package:org.zooper.zwpro Name:Zooper Widget Pro Variable Timeout (Seconds):0 ] 
 A6: Variable Split [ Name:%mwwotd Splitter:word_function"> Delete Base:Off ] 
 A7: Variable Split [ Name:%mwwotd2 Splitter:</p> Delete Base:Off ] 
 A8: Variable Convert [ Name:%mwwotd21 Function:HTML to Text Store Result In: ] 
 A9: Zooper Widget Pro Variable [ Configuration:#Tmwfunc# = %mwwotd21 Package:org.zooper.zwpro Name:Zooper Widget Pro Variable Timeout (Seconds):0 ] 
 A10: Variable Split [ Name:%mwwotd Splitter:<span class="ssens"> Delete Base:Off ] 
 A11: Variable Split [ Name:%mwwotd2 Splitter:</span> Delete Base:Off ] 
 A12: Variable Convert [ Name:%mwwotd21 Function:HTML to Text Store Result In: ] 
 A13: Zooper Widget Pro Variable [ Configuration:#Tmwdef1# = %mwwotd21 Package:org.zooper.zwpro Name:Zooper Widget Pro Variable Timeout (Seconds):0 ] 
 A14: Variable Split [ Name:%mwwotd Splitter:<span class="ssens"> Delete Base:Off ] 
 A15: Variable Split [ Name:%mwwotd3 Splitter:</span> Delete Base:Off ] 
 A16: Variable Convert [ Name:%mwwotd31 Function:HTML to Text Store Result In: ] 
 A17: Zooper Widget Pro Variable [ Configuration:#Tmwdef2# = %mwwotd31 Package:org.zooper.zwpro Name:Zooper Widget Pro Variable Timeout (Seconds):0 ] 
 A18: Variable Split [ Name:%mwwotd Splitter:<span class="ssens"> Delete Base:Off ] 
 A19: Variable Split [ Name:%mwwotd4 Splitter:</span> Delete Base:Off ] 
 A20: Variable Convert [ Name:%mwwotd41 Function:HTML to Text Store Result In: ] 
 A21: Zooper Widget Pro Variable [ Configuration:#Tmwdef3# = %mwwotd41 Package:org.zooper.zwpro Name:Zooper Widget Pro Variable Timeout (Seconds):0 ] 
 A22: Variable Split [ Name:%mwwotd Splitter:word_example_didu"> Delete Base:Off ] 
 A23: Variable Split [ Name:%mwwotd2 Splitter:</p><div class="sidexside"> Delete Base:Off ] 
 A24: Variable Convert [ Name:%mwwotd21 Function:HTML to Text Store Result In: ] 
 A25: Zooper Widget Pro Variable [ Configuration:#Tmwexam1# = %mwwotd21 Package:org.zooper.zwpro Name:Zooper Widget Pro Variable Timeout (Seconds):0 ] 
 A26: Variable Split [ Name:%mwwotd Splitter:word_example_didu"> Delete Base:Off ] 
 A27: Variable Split [ Name:%mwwotd3 Splitter:<br /><br /> Delete Base:Off ] 
 A28: Variable Convert [ Name:%mwwotd31 Function:HTML to Text Store Result In: ] 
 A29: Zooper Widget Pro Variable [ Configuration:#Tmwexam2# = %mwwotd31 Package:org.zooper.zwpro Name:Zooper Widget Pro Variable Timeout (Seconds):0 ] 

Bob Hansen

unread,
Nov 24, 2013, 1:52:33 PM11/24/13
to tas...@googlegroups.com
The easiest way to determine if there are mulltiple definitions is to simply search for "snum" if it exists in the %mwwotd then it has multiple definitions.

To get the number of definitions you can do this:

Variable Search [ %mwwotd  Search: "snum"  (with quotes)   Store Matches In: %matches  ]

%matches will be an array of the occurrences of the "snum". You can reference them as %matches(1), %matches(2), etc.

The number of occurrences will be returned by %matches(#).

Tasker Newbie

unread,
Nov 24, 2013, 2:12:37 PM11/24/13
to tas...@googlegroups.com
Hey Bob, 

thank you for your effort but i dont get it. 

Do i have to do something like if > variable search snum > 1 then blabla else blabla

Anyways i have no clue what i can do with the referenced snums. It doesnt save the definition just with snum right? 

Bob Hansen

unread,
Nov 24, 2013, 2:24:28 PM11/24/13
to tas...@googlegroups.com
Yes. Your request was a way to know if there were more than one definition.

Once you know how many definitions there are you can parse out any or all of them.
Did you want to get all the definitions?

Tasker Newbie

unread,
Nov 24, 2013, 2:33:11 PM11/24/13
to tas...@googlegroups.com
okay, i made a little progress, but have one issue left. 

The word of today has two definitions. When i change the link in the get request to a word with just one definition, there still is a second definition left from the other word. Vaporware (wotd from the past) actually has just one definition, which is displayed just fine, but in addition it has a second one from exact (wotd from today)

MW-Wotd (15)
A1: HTTP Get [ Server:Port:http://www.merriam-webster.com Path:word-of-the-day/2013/11/01 Attributes: Cookies: Timeout:10 Mime Type:text/html Output File:Tasker/mw-wotd.txt ] 
A2: Read File [ File:Tasker/mw-wotd.txt To Var:%mwwotd ] 
A3: Variable Split [ Name:%mwwotd Splitter:main_entry_word"> Delete Base:Off ] 
A4: Variable Split [ Name:%mwwotd2 Splitter:</strong> Delete Base:Off ] 
A5: Zooper Widget Pro Variable [ Configuration:#Tmwword# = %mwwotd21 Package:org.zooper.zwpro Name:Zooper Widget Pro Variable Timeout (Seconds):0 ] 
A6: Variable Split [ Name:%mwwotd Splitter:word_function"> Delete Base:Off ] 
A7: Variable Split [ Name:%mwwotd2 Splitter:</p> Delete Base:Off ] 
A8: Variable Convert [ Name:%mwwotd21 Function:HTML to Text Store Result In: ] 
A9: Zooper Widget Pro Variable [ Configuration:#Tmwfunc# = %mwwotd21 Package:org.zooper.zwpro Name:Zooper Widget Pro Variable Timeout (Seconds):0 ] 
A10: Variable Search Replace [ Variable:%mwwotd Search:"snum" Ignore Case:Off Multi-Line:Off One Match Only:Off Store Matches In:%snum Replace Matches:Off Replace With: ] 
A11: Zooper Widget Pro Variable [ Configuration:#Tsnum# = %snum Package:org.zooper.zwpro Name:Zooper Widget Pro Variable Timeout (Seconds):0 ] 
A12: If [ %snum > 0 ]
A13: Variable Split [ Name:%mwwotd Splitter:<span class="ssens"> Delete Base:Off ] 
A14: Variable Split [ Name:%mwwotd2 Splitter:</span> Delete Base:Off ] 
A15: Variable Convert [ Name:%mwwotd21 Function:HTML to Text Store Result In: ] 
A16: Zooper Widget Pro Variable [ Configuration:#Tmwdef1# = %mwwotd21 Package:org.zooper.zwpro Name:Zooper Widget Pro Variable Timeout (Seconds):0 ] 
A17: Variable Split [ Name:%mwwotd Splitter:<span class="ssens"> Delete Base:Off ] 
A18: Variable Split [ Name:%mwwotd3 Splitter:</span> Delete Base:Off ] 
A19: Variable Convert [ Name:%mwwotd31 Function:HTML to Text Store Result In: ] 
A20: Zooper Widget Pro Variable [ Configuration:#Tmwdef2# = %mwwotd31 Package:org.zooper.zwpro Name:Zooper Widget Pro Variable Timeout (Seconds):0 ] 
A21: Variable Split [ Name:%mwwotd Splitter:<span class="ssens"> Delete Base:Off ] 
A22: Variable Split [ Name:%mwwotd4 Splitter:</span> Delete Base:Off ] 
A23: Variable Convert [ Name:%mwwotd41 Function:HTML to Text Store Result In: ] 
A24: Zooper Widget Pro Variable [ Configuration:#Tmwdef3# = %mwwotd41 Package:org.zooper.zwpro Name:Zooper Widget Pro Variable Timeout (Seconds):0 ] 
A25: Else 
A26: Variable Split [ Name:%mwwotd Splitter:<span class="ssens"> Delete Base:Off ] 
A27: Variable Split [ Name:%mwwotd2 Splitter:</span> Delete Base:Off ] 
A28: Variable Convert [ Name:%mwwotd21 Function:HTML to Text Store Result In: ] 
A29: Zooper Widget Pro Variable [ Configuration:#Tmwdef1# = %mwwotd21 Package:org.zooper.zwpro Name:Zooper Widget Pro Variable Timeout (Seconds):0 ] 
A30: End If 
A31: Variable Split [ Name:%mwwotd Splitter:word_example_didu"> Delete Base:Off ] 
A32: Variable Split [ Name:%mwwotd2 Splitter:</p><div class="sidexside"> Delete Base:Off ] 
A33: Variable Convert [ Name:%mwwotd21 Function:HTML to Text Store Result In: ] 
A34: Zooper Widget Pro Variable [ Configuration:#Tmwexam1# = %mwwotd21 Package:org.zooper.zwpro Name:Zooper Widget Pro Variable Timeout (Seconds):0 ] 
A35: Variable Split [ Name:%mwwotd Splitter:word_example_didu"> Delete Base:Off ] 
A36: Variable Split [ Name:%mwwotd3 Splitter:<br /><br /> Delete Base:Off ] 
A37: Variable Convert [ Name:%mwwotd31 Function:HTML to Text Store Result In: ] 
A38: Zooper Widget Pro Variable [ Configuration:#Tmwexam2# = %mwwotd31 Package:org.zooper.zwpro Name:Zooper Widget Pro Variable Timeout (Seconds):0 ] 

Bob Hansen

unread,
Nov 24, 2013, 2:45:47 PM11/24/13
to tas...@googlegroups.com
The best way is to use local variables (all lowercase). These only exist as long as the task is running and tasker doesn't remembert then. For global variables (with at least 1 uppercase character) you need to use Variable Clear.

Tasker Newbie

unread,
Nov 25, 2013, 9:06:10 AM11/25/13
to tas...@googlegroups.com
Hey Bob, 

thank you for your tips. This helped me a lot. Almost done :) 
Reply all
Reply to author
Forward
0 new messages