Search this site


Metadata

Articles

Projects

Presentations

jquerycmd+xpathtool == direction scraping on google

Show the first 3 steps that google maps tells you to take.
./getpath.sh "atlanta to nyc" | head -3
Head southeast on Trinity Ave SW toward Washington St SW        0.2mi
Slight left at Memorial Dr SW   0.3mi
Turn left at Martin St SE       361ft
Pipe that to lpr and you've got printed directions on under 5 seconds.

Why not just do this with plain page scraping? Because there's lots of javascript in google maps that presents the user with the directions. Firefox (Gecko, really) already parses it, so why bother reinventing the wheel? Let's use the wheel that already works.

Download jquery-20070623.1828.tar.gz. The download of jquerycmd comes with the xul app, 'jquerycmd.sh' and 'getpath.sh'.

For the lazy who just want to see the scripts: