Last active
June 27, 2016 22:01
-
-
Save joneskoo/ad768f78a3b7fbaa5e965460bdd75cab to your computer and use it in GitHub Desktop.
Fetch raw consumption data from www.energiatili.fi (curl)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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