Skip to content

Instantly share code, notes, and snippets.

@joneskoo
Last active June 27, 2016 22:01
Show Gist options
  • Save joneskoo/ad768f78a3b7fbaa5e965460bdd75cab to your computer and use it in GitHub Desktop.
Save joneskoo/ad768f78a3b7fbaa5e965460bdd75cab to your computer and use it in GitHub Desktop.
Fetch raw consumption data from www.energiatili.fi (curl)
#!/usr/bin/curl -K
# Global options
#verbose
cookie-jar /dev/null
# Request 1: Log in (and follow redirects)
location
output /dev/null
data @secrets/www.energiatili.fi
url https://www.energiatili.fi/Extranet/Extranet/LogIn
next
# Request 2: Get consumption data
compressed
output power.html
url https://www.energiatili.fi/Reporting/CustomerConsumption/UserConsumptionReport
all: data.json
clean:
rm -f data.json power.html
power.html:
./get-power-data.curl
data.json: power.html
cat $< | grep ' var model =' \
| tr -d '\\\r' \
| sed -e 's# *var model = ##' \
| sed -e 's#new Date(\([-0-9]*\))#\1#g' \
| sed -e 's/;//' \
| jq -c . > $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment