Skip to content

Instantly share code, notes, and snippets.

@stilvoid
Last active June 24, 2016 01:19
Show Gist options
  • Save stilvoid/a3a0c5c03dda031640aab7570a068410 to your computer and use it in GitHub Desktop.
Save stilvoid/a3a0c5c03dda031640aab7570a068410 to your computer and use it in GitHub Desktop.
#!/bin/bash
url="https://public.broker.elections.api.bbci.co.uk/components/batch?components%5Beu_ref_banner_data_en%5D%5Bcomponent%5D=eu_ref_banner_data_en&components%5Beu_ref_ticker_en%5D%5Bcomponent%5D=eu_ref_ticker_en&components%5Bpolling_policy%5D%5Bcomponent%5D=polling_policy"
in=$(curl "$url" 2>/dev/null | jq -r .components[0].body | jq -r .remainVoteCount | sed -e 's/[^0-9]//g')
out=$(curl "$url" 2>/dev/null | jq -r .components[0].body | jq -r .leaveVoteCount | sed -e 's/[^0-9]//g')
turnout=$(curl "$url" 2>/dev/null | jq -r .components[0].body | jq -r .turnoutPercentage)
remaining=$(curl "$url" 2>/dev/null | jq -r .components[0].body | jq -r .leftToDeclare)
total=$(($in + $out))
echo -n "Out: $out ($((100 * $out / $total))%)"
echo -n " - "
echo -n "In: $in ($((100 * $in / $total))%)"
echo -n " - "
echo "$turnout turnout"
echo -n "Diff: $(($in - $out))"
echo -n " with "
echo "$remaining "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment