From 380982b971cda40c5cc509b53eba6d2b9a0d03ab Mon Sep 17 00:00:00 2001 From: adrianshort Date: Wed, 9 Mar 2016 14:21:48 +0000 Subject: [PATCH] --- get.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 get.sh diff --git a/get.sh b/get.sh new file mode 100644 index 0000000..940909d --- /dev/null +++ b/get.sh @@ -0,0 +1,26 @@ +#!/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 -