I got this annoying problem - my cable modem start acting weird after a while. So I wanted to setup cron job to restart it sometimes around 3am each day, but the problem is - there is no SSH or any kind of API access. But there is admin panel where you can click "Reboot" button. To solve this problem I used Zombie.js module:
sudo npm install zombie -g
and wrote small script to login into admin interface and click Reboot button:
#!/usr/bin/node var Browser = require("zombie"); var browser = new Browser(); browser.visit("http://192.168.0.1/", function() { browser .fill('loginUsername', 'admin') .fill('loginPassword', 'password') .pressButton("Login", function() { browser.visit("http://192.168.0.1/RgConfiguration.asp", function() { browser.pressButton("Reboot"); }); }); });
Make it executable:
chmod +x reboot.js
And add it to crontab job:
* 3 * * * cd ~/bin/reboot_router && ./reboot.js
Done!
You potentially may automate much more tasks the same way. Zombie, unlike Phantom.JS or Casper.JS do not use webkit/gecko, therefore it is much more lightweight and does not require X. Downside of not being "real" browser engine is that it might not work well on sites with heavy use of Javascript, like Facebook. But for simpler pages it works very well!