This article shows how to use a Private Plugin to monitor a page for a specific price.
The price in the red ellipsis is the price we want to monitor and WebSite-Watcher should only alert an update if this price is lowered against the locally saved version.
Launch the Plugin IDE
Open the bookmark properties, then select “Advanced” + “Plugin” + “Private Plugin” and click the button “Create Private Plugin”.
This will open the Plugin IDE with the following tabs:
The “Plugin Script” tab is the section where you can enter the Plugin script (in “Basic” language). The other tabs are used to display the page source, the rendered page and the source code of other plugins.
To remember, a Plugin must contain one or more Event functions which are called from WebSite-Watcher at appropriate times. The Event function Wsw_CompareVersions is used to compare the web version of a page with the locally saved version, you can filter the content (in our case the price) and decide when an update notification should be made.
Extracting the price
In a first step, we have to implement a function that extracts the price from the page source. We use the following “Basic” code:
Function ExtractPrice(sMem) As IntegerDim p, nLenExtractPrice = -1' Skip "List Price:" If FindString(sMem, "List Price:", p, nLen) Then Delete(sMem, 1, p + nLen) End If' Extract price If FindString(sMem, "Price:", p, nLen) Then Delete(sMem, 1, p) If FindRegex(sMem, "\$\d+\.\d+", p, nLen) Then sMem = ExtractDigits(Copy(sMem, p, nLen)) ExtractPrice = CInt(sMem) End If End If End Function
This function extracts all digits from the price and $8.99 becomes 899. This doesn’t matter for only comparing the price.
Comparing prices via the Event function
With “Insert + WSW Event functions” you can insert the function “Wsw_CompareVersions”. WebSite-Watcher calls this function with the source code of the web page and the source code of the locally saved version. The only thing we have to do is to extract the prices (with the function above), compare them and return the result of the comparison:
Sub Wsw_CompareVersions(Handle, ByRef sMemWeb, ByRef sMemLocal, ByRef sStatusMessage, ByRef iStatusCode)Dim nPriceNew, nPriceOld' Extract prices nPriceNew = ExtractPrice(sMemWeb) nPriceOld = ExtractPrice(sMemLocal)' Return only the price - this will speed up several WSW routines, eg. "Test filter" dialog ' and makes testing easier sMemWeb = CStr(nPriceNew) sMemLocal = CStr(nPriceOld)If nPriceNew = -1 Then iStatusCode = 2 sStatusMessage = "Error extracting price" ElseIf nPriceNew < nPriceOld Then iStatusCode = 1 sStatusMessage = "Price lowered to EUR " + CStr(nPriceNew / 100) End If End Sub
iStatusCode is an integer value and indicates if a page has been changed or if an error has occurred. Valid values are:
- 0 … OK, page is unchanged. This is the default value and must not be assigned manually.
- 1 … OK, page has been changed. The bookmark will be marked as updated.
- 2 … Error. If 2 is returned, the check of that bookmark will be aborted with an error.
Assigning a text to sStatusMessage is optional and will be displayed in the status column of the bookmark list. The default value is an empty string.
After the script has been entered, click the OK button to return to the bookmark properties. From now on you will only get update notifications when the price is lowered.







