I use the USForex currency exchange for sending money from Australia to the USA. They offer a service where they quote you an exchange rate at which you can transfer money between countries, without the cost and hassle of a wire transfer.
I really like their service: you can set up regular payments if you don’t mind what the exchange rates are, or you can use spot deals to transfer at the latest possible exchange rate. Their fees are built in to their quotes, and you simply transfer money to their account in Australia, and they pay into your US account (or vice-versa) a day or two later.
One feature they offer is a built-in alert system where you can be notified if the rate changes above or goes below specified thresholds. Their built-in alert system was terrible, mainly because it was too slow - by the time you received a text or read an email, the rate had changed, often significantly.
I wanted to solve this problem by having a screen scraper log in, get a quote for an exchange rate and make that available to me on my laptop during the day.
Below shows the final result - GROWL-style notifications popping up every 20 minutes. This provides that flexibility to properly monitor the exchange rate.
So, how did we achieve this?
After looking at all sorts of Java HTTP/HTML solutions like htmlclient and Selenium, I finally settled on using headless browser technology to scrape websites.
The CasperJS on top of PhantomJS solution offers excellent full-blown WebKit features, with the ease of a domain-specific language in Javascript.
I highly recommend grabbing Resurrectio, a chrome extension that really helps you learn how casper works, and make authoring scripts by example a breeze.
After installation, the Javascript flavor you author scrapers in is reasonably high level.
Full code is available at this GitHub repository.
Here is a sample of the top of the scraper for us forex:
It turns out you can create notifications from a Terminal command line, following the instructions in this article.
Armed with this knowledge, I created the following shell script that runs the scraper, grabs the exchange rate, and displays a notification. It does so every 20 minutes.