Skip to content

Instantly share code, notes, and snippets.

@pmgupte
Created May 23, 2019 09:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pmgupte/996523c62b160bdbe4b11e9c34a57d74 to your computer and use it in GitHub Desktop.
Save pmgupte/996523c62b160bdbe4b11e9c34a57d74 to your computer and use it in GitHub Desktop.
Get results for General Election in India 2019
#!/bin/bash
RED="\033[1;31m"
GREEN="\033[1;32m"
NOCOLOR="\033[0m"
YELLOW="\e[33m"
BLINK="\e[5m"
NOBLINK="\e[25m"
echo "Getting result from http://results.eci.gov.in..."
curl -# -A "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0" -o /tmp/result.html "http://results.eci.gov.in/pc/en/partywise/index.htm"
sed -i "s/^<td.align='left'>//g" /tmp/result.html
sed -i "s/\(<\/td><td align='center'>\)/, /g" /tmp/result.html
sed -i "s/<\/td>$//g" /tmp/result.html
echo "Party, Won, Leading"
echo "-------------------"
grep -E "(Bharatiya Janata Party|Indian National Congress)" /tmp/result.html
warning=`grep -o "The trends displayed.*validity\." /tmp/result.html`
updated=`grep -o "Last Updated at.*2019" /tmp/result.html`
echo -e "${GREEN}${updated}${NOCOLOR}"
echo -e "${YELLOW}${warning}${NOCOLOR}"
rm /tmp/result.html
@pmgupte
Copy link
Author

pmgupte commented May 23, 2019

Sample output:

root@pg-ubuntu:~# eci
Getting result from http://results.eci.gov.in...
######################################################################## 100.0%
Party, Won, Leading
-------------------
Bharatiya Janata Party, 1, 299
Indian National Congress, 0, 50
Last Updated at  03:20:02 pm On 05/23/2019
The trends displayed are based on the data entry done by ARO/RO as when they complete these rounds and is subject to change.Only Result signed and declared by Returning officer has the statutory validity.
root@pg-ubuntu:~#

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment