3 ms·
Here is a simple script to grab election results from AP via The Guardian. No API key required. No over-enegineered "ELEX" Python scripts. Just request the J
by 1vuio0pswjnm7 6y ago
Here is a simple script to grab election results from AP via The Guardian. No API key required. No over-enegineered "ELEX" Python scripts. Just request the JSON and do whatever you want with the numbers.
Usage: 1.sh [2-letter state abbrev uppercase]
Example: 1.sh PA
cat > 1.sh
#!/bin/sh
x=$(curl https://interactive.guim.co.uk/2020/11/us-general-election-data/prod/last_updated.json|sed -n '/"time":/{s/{"time":"//;s/"}//;p;}')
curl https://interactive.guim.co.uk/2020/11/us-general-election-data/prod/data-out/$x/president_details.json|sed 's/.*\"'"$1"'\"://;s/\"[A-Z][A-Z]\":.*//;s/,/\
/g;s/"candidates":\[//;'
echo $x
^D