tomtaylor.co.uk

Blog

ATMs I Am Near

Thursday, May 15th, 2008 at 7:57 pm in Projects & Tinkering.

Tagged with: , , , , , .

I just launched ATMs I Am Near, which does exactly what it says on the tin. I know ATMs is American English, but cashmachines is longer to type on a mobile.

Banksy-Cashpoint

The data is pulled out of the LINK ATM Locator, which is one of those javascript powered bit of web weirdness that can only come out of Enterprise Software. A quick poke at the code reveals how it works. Firstly, in one request, it converts the search query (postcode, town name, etc.) into a longitude and latitude. Secondly, in another request, it performs an AJAX request with the co-ordinates and options, and returns JSON. It’s easy to stick the longitude and latitude returned from Fire Eagle in that request, and parse the results.

However, to return the results, a number of HTTP headers are needed (Referer: http://locator.link.co.uk/, X-Requested-With: XMLHttpRequest). The bounding box it expects seems to be required, but can be ignored (set both the longitude and latitude to zero). It looks something like:

JSON.parse(`curl -H "Referer: http://locator.link.co.uk/" -H "X-Requested-With: XMLHttpRequest" -d "q=list&ne=0%2C0&sw=0%2C0&ll="#{lon}"%2C#{lat}&st=atm&mptu=N&pms=N&wc=N&ta=N&height=A&_=" "http://locator.link.co.uk/ATMWebLocator/LocatorDataServlet" -s`)

Unfortunately, I have no control over the data, and I know it’s not perfect. There are some duplicates, and some strange capitalisation. But, dammit, it works!

Comments

Comments are closed.