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


~/bin/cric

#!/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

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


Bonus: cool poll function

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
}