Created
May 23, 2019 09:43
-
-
Save pmgupte/996523c62b160bdbe4b11e9c34a57d74 to your computer and use it in GitHub Desktop.
Get results for General Election in India 2019
This file contains 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
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sample output: