Homemade Automatic Domain Tester with PhantomJS Part 1
21 Feb 2015Reason Why
I had an idea to write a program that automatically checked a list of websites to make sure they were still running. The idea is that I could later modify this program to contact me if a site was down.
Tools within My Reach
- Raspberry Pi
- JavaScript
- PhantomJS
- A list of websites to test
A Little Background
I started this adventure off using Selenium Webdriver written in Ruby and running on the Raspberry Pi. This combonation worked, however it was a little sluggish on the Pi. I needed something a little lighter and faster!
PhantomJS
If you haven’t played around with PhantonJS yet, I recommend you do. They have a really great ‘quick start’ section to show you the power of PhantomJS.
Installing PhantomJS
If you don’t have PhantomJS installed go ahead and get the latest version.
The First Version
Below I’ve included the first version of my PhantomJS Domain Tester. This version visits each site that you put inside the ‘arrayProdsites’ array, observes redirects and reports back the status of the site. (success or failed)
How to Run
After you copy this code to a .js file on your system, go ahead and run the following command…
Shortly after you should see the status of each domain test.
Possible next steps
I might want to hook this up to a cron job so that it will fire off automatically based on a schedule. That being said, I may also want to create some way for it to report its suspected failures.
Try It Yourself!
Feel free to modify and improve this code to your desire. The code can also be found here.