#!/usr/bin/env sh # Download PDF files for a planning application from Sutton Council planning website # If you run this more than once it'll only download the new files uploaded for that application. # Usage: $ get.sh , e.g. $ get.sh B2015/71962 # Install curl and wget before use. Mac users can install them with Homebrew. # Windows users: Try running this in Cygwin or install Linux in a virtual machine. # Adrian Short 26 Feb 2016 COOKIEJAR=cookiejar.txt mkdir -p $1 cd $1 curl -s -c $COOKIEJAR 'http://gis.sutton.gov.uk/FASTWEB/welcome.asp' > /dev/null # Get the session cookies curl -s -c $COOKIEJAR \ --data "cbxCopyrightStatement=on" \ --data "ApplicationNumber=$1" \ 'http://gis.sutton.gov.uk/FASTWEB/images.asp' \ | grep -E -o 'http.+?\.(pdf|PDF)' \ | wget --no-clobber -i - rm $COOKIEJAR ls -lht cd -