Live Cricket Score in Terminal

Command-line script to fetch latest scores of Live matches of Cricket. Uses pyquery.


~/bin/cric

1
2
3
4
5
6
7
8
9
10
#!/usr/local/bin/python
from pyquery import PyQuery as pq

data = pq(url='https://cricket.yahoo.com/cricket/live-score/')
live = data('.live.events')

for idx, event in enumerate(live):
for line in live.find('.event-info div'):
print pq(line).text().strip()
print ''

cric | pbcopy

1
2
3
4
5
LIVE
BLR 12/1 (1.3 Overs)
GL 158/10;
Bengaluru, India
Indian Premier League, 201...

Bonus: cool poll function

1
2
3
4
5
6
7
8
9
10
11
function cric() {
IFS=$'\n' #'
tput sc
while true; do
tput rc; tput ed;
for line in `~/bin/cric`; do
printf "$line\n"
done
sleep 30
done
}