How to set up a content change watchdog for any website in 5 minutes
Some websites, typically in the area of e-commerce, provide a feature called a watchdog that you can use to get a notification when something changes (usually a product price). This is really handy — you don’t need to remember to regularly open the same page to see if something changed. Now, with a new public actor on Apify, you can set up such a watchdog for any website and get an email notification whenever the content you want to monitor changes.
Just think about how often you’ve checked the same page every evening to see if tickets are already on sale, a product price is below the price you want to pay, your competitor changed his homepage or there’s new version of a library you are dependent on.
Now all you have to do is:
- Have an account on Apify (the free one will work for most cases)
- Create a Task for a generic Content Checker Actor with URL, content selector and email address for notification as an input
- Schedule your Task (to run hourly, for example)
Once this is set, your task will run periodically on the Apify platform and send you a notification when the content of the selector you’ve defined changes. Here’s an example of such a notification:
Step-by-step tutorial
Imagine you have a project running on Kickstarter and want to get a notification when the pledged amount changes. Kickstarter doesn’t provide native notifications or an API for that, so let’s set up a watchdog on Apify.
- Create a free account on apify.com if you don’t already have one
- Hit the Try actor button on the Content Checker public page
- Click on the Create task button
In the Input tab, you see the default configuration (monitoring Apify’s changelog):
4. Set URL to check (e.g. this handy Kickstarter project)
5. Set Monitored area selector, i.e. the CSS selector you want to check
You can use Chrome developer tools for step 5 (right-click on the text you want to monitor, select Inspect and find the correct CSS selector):
Or you can use our Page Analyzer. Just fill in the URL and actual text content. Page Analyzer checks the page and tries to find the CSS selector for you. You can find it in the HTML section:
In our case, we’ll use this selector to monitor the amount pledged: “.mb2-lg .flex”
6. You can optionally set Screenshot selector, which is used to get and send screenshots in the email notification (previous and current screenshot)
You can find the CSS selector for the screenshot in the same way as for the Content selector. If you don’t define it, the CSS selector for content will be used for the screenshot. In our case, we use “.col-full.block-lg .flex”
7. Set an email address for notification
So, our Task input looks like this now:
8. Give your Task a name (optional)
You can set a name for your task in the Settings tab:
9. Schedule your Task
Go to the Schedules section and create a new Scheduler:
You can name your Scheduler and set a Cron expression defining how often your task will run. You can keep @daily there.
Go to the Tasks tab, choose your Task and click Save:
And that’s it — you’re all set. The Task will run every day, scrape the content of your selector, compare it with the previous run and send you a notification if the content changes (along with previous and current content and screenshot).
You can see the complete documentation and source code of the Content Checker Actor in this GitHub repository. If you come across any problems when using this actor, just create an issue there.
Happy monitoring!