I'm looking for a macro (or tool) that regularly (say every hour) checks a certain web page and gives an unobtrusive notice (e.g. by placing a text file ("New version.txt") on the desktop (or via any other unobtrusive way of warning that sticks and doesn't hinder any wild monkey typing).
One simplistic way to do it, which will cause all sorts of false alerts if the page has regularly-updated meaningless content (i.e. a clock or timer or whatever), would be this:
Start by checking to see if you've already saved the contents of the page: Does a file named /tmp/page_original.html
(or whatever the path/name you choose) exist?
If no, then save the contents of the page as HTML to that name/location. You can do this using curl
with the -o
option:
curl -o /tmp/page_original.html http://wordfast.net/plustools/
If the file does exist, save a new copy:
curl -o /tmp/page_newsave.html http://wordfast.net/plustools/
Now you have two copies you can compare:
diff /tmp/page_newsave.html /tmp/page_original.html
Save the results to a variable, then check if it's blank or not. If not blank, issue your alert, because the page changed. (You could also search the var to find out exactly what changed, and if it's something that's of interest to you.)
As the last step, delete page_original.html
and rename page_newsave.htmnl
to page_original.html.
Now the macro is ready to run again on its next timed cycle.
-rob.
Is the web page you cited the web page you want to monitor? Are you checking for version number changes? There are a few ways to get the "text" off of a web page. Is that what you want to do?
Yes it is.
Thanks, @Airy, for asking the "forest or trees?" question I always forget about :). You could do what you want with JavaScript, but here's a version that just grabs the whole page (as it's small), then uses regex to extract the version and date:
Get version number of PlusTools.kmmacros (3.4 KB)
You could do whatever you want with the extracted info: Set it to Global_newValue
and compare that to Global_oldValue
then swap them (as I did with the files), or write it to a file and do the same thing, etc.
-rob.