4 ms·
>we will need to define two global variables Or just pass them to the request functions. And why define the global LOOP_EVERY_SECONDS in terms of seconds, rath
by nemo1618 10y ago
>we will need to define two global variables
Or just pass them to the request functions. And why define the global LOOP_EVERY_SECONDS in terms of seconds, rather than a time.Duration?
This code also doesn't handle errors at all. And it can exit any time from within checkChanges. And it compares data by converting the []byte to a string. Use bytes.Equal instead.
Finally, wouldn't this be a bit more useful if it printed a diff of the old-vs-new?
- bootload 10y ago"wouldn't this be a bit more useful if it printed a diff of the old-vs-new?" I like the idea. If I had to do this quickly, I'd be tempted to use cron, diff and wget as a script. I can't see any handling of HTTP response codes [0] so lots of things could happen that need handling. Does Go have equivalent to the fabulous python ^Requests^ by Kenneth Reitz? [1] Page diffs is a nice feature I might add to a page size tool I hacked up. [2] Reference [0] https://tools.ietf.org/html/rfc2616#section-6 https://tools.ietf.org/html/rfc2616#section-6 [1] https://github.com/kennethreitz/requests https://github.com/kennethreitz/requests [2] https://github.com/peterrenshaw/pageglut https://github.com/peterrenshaw/pageglut
- pimlottc 10y agoHandling errors is 90% of the job for a page monitor like this. Have fun getting spammed when the site goes offline briefly, or when your internet connection goes down.
- ssimunic 10y agoGood point. Added error checking.