serverless-web-differ
serverless-web-differ copied to clipboard
A serverless web browser which crawls websites and compares pages by schedule.
Serverless Web Differ
中文文档
A serverless web browser which crawls websites and compares pages by schedule, with Serverless, AWS Lambda, Headless Chrome and Selenium!
What it can do | Prerequisites | Configuration | Deploy
What it can do
- Runs headless chrome in a serverless environement.
- Finds web elements with xpath and compares it.
- Send notifications/emails if something has changed.
Prerequisites
- You need to have a aws account,
aws_access_key_idandaws_secret_access_key. If you don't an account yet, go to here to sign up for one, and then follow the instructions here to get the key_id and access key. - Install node and make sure
npmis available in your path. - Install docker from here.
- Install Serverless:
npm install -g serverless - Configure serverless with aws, using the
aws_access_key_idandaws_secret_access_keyfrom step 0:sls config credentials -p aws -k aws_access_key_id -s aws_secret_access_key - Clone this project:
git clone https://github.com/LeiShi1313/serverless-web-differ.git - Install the dependencies:
cd serverless-web-differ && npm install
Configuration
There are couple of things you need to configure before actually make the function running in the cloud. First you need to create a file called config.yml and copy/paste everything from config.yml.example. Inside the config.yml:
events: This is the place you can define what is the frequency the function runs, you can read more from here. But most of the time, you want one entry like- schedule: rate(1 hour)or- schedule: cron(0 * * * ? *), which both means run the function every hour.server_chan/sendgrid/ifttt/pushbullet: There are the pre-defined ways to notify you if something has changed on the websites you interested. You can read the comments to find out how to get the security keys.websites: This is the main configuration part.websitescan have multiple entries, and each one represents a website you want to periodically check.urlandxpathis easy to understand, if you don't know how to get the xpath, try searchxpath [THE BROWSER YOU ARE USING], you should be able to find a lot of informations. Fororiginal, actually it can be absent if you are expecting a web element will appear, otherwise the function will compare the EXACT text fromoriginaland the web element of the web page byxpath.
Deploy
This is simple, when everything is all set, run:
sls deploy
and :tada::tada::tada:
TODO
- [x] Add Chinese ver. README.
- [ ] For each
website, deploy a lambda function instead of visiting all websites in one function. - [ ] Make
notify.pyanother lambda function. - [ ] Add more ways to notify.
- [ ] Maybe move
notify.pyto another project and make a submodule here? - [ ] Provide a headerless chrome docker image
- [ ] Options for other cloud provider: Google Cloud, Aliyun, etc