Simple example of using search patternsWatzNew utilizes a simple to create yet powerful search pattern scheme to retrieve specific data from html pages. When the data is retrieved, WatzNew takes the message template to form a user-friendly message. When the html page is loaded, WatzNew applies the search pattern first. The date / time macros are inserted before the search is performed, so you can make date-based search. Sample search pattern: |
This means: find the first occurence of <H1> in the html document and treat any text between it and the following occurence of </H1> as the first parameter (that corresponds to %1 in message template).
|
After then the extracted parameters are substituted into the message template. Sample message template: |
This means: substitute %1 with the first parameter found.
|
If we apply the above rules to the following sample html document
... <BODY> <H1>"How to become rich?" by John Poor</H1>
... </BODY> |
we will get "Current article: "How to become rich?" by John Poor" message.Now, when the text between <H1> and </H1> is changed, we will be notified with such a message as soon as WatzNew checks the channel for updates. | Note: Pattern search is case-insensitive but date / time macros that are inserted before search, are case-sensitive; each found parameter is processed on the following scheme: html tags (simply all text between < and >) are stripped; all are converted to spaces; all &nn; and &nnn; and such codes as ©, ®, " are converted to corresponding characters; the resulting strings are trimmed (all leading and trailing spaces and control characters are removed).
|
Please take a look at the more complex example of using search patterns and message templates. |