Get live match score update on your computer
If you don't want to look at the score websites again and again. If you want score to pop up after regular interval. If you want to continue with your work and still be updated with the cricket match proceedings ... here is a script for you.
I wrote a script that would fetch the score json object from
espncricinfo.com website that contains the live score. This json object is always updated with the latest score and it is used to render the live score page of the website. The script notifies you with the score update at a regular interval of time with a small pop up that eventually fades away in some time.
You need to have following python modules before you run the script.
- time
- json
- notify2
- urllib2
To install
notify2 execute following statement:
sudo apt-get install python-notify2
To install
notify2 using
pip execute following statement:
Typically other modules are built-in in python. Still if you get any error during execution of script you can easily install other modules in your system.
To execute the script, follow the following steps:
Step 1: Open the live match page on espncricinfo website.
This page is the one where you see the score of the match in progress. The URL looks something like this.
http://www.espncricinfo.com/pakistan-zimbabwe-2015/engine/match/868731.html
Step 2: Pick the last number from the URL.
Step 3: Open the script and replace XXXXXX with this number.
Step 4: Execute the script.
You should see output something like this:
import notify2
import time
import urllib2
import json
match_url = 'http://www.espncricinfo.com/ci/engine/match/XXXXXX.json'
proxy = urllib2.ProxyHandler(
{
'http': 'put_proxy_here',
'https': 'put_proxy_here'
}
)
""" In Case you have proxy uncomment line below """
"""opener = urllib2.build_opener(proxy)"""
""" When No Proxy un-comment line below """
opener = urllib2.build_opener()
urllib2.install_opener(opener)
notify2.init('cricnot')
while True:
r = urllib2.urlopen(match_url)
j = json.loads(r.read())
msg = j['live']['status']
for i in j['centre']['batting']:
msg += ('<br/>' + i['popular_name'] + ' - ' + i['runs'] + ' (' + i['balls_faced'] + ')')
n = notify2.Notification(j['description'].split(':')[0],msg)
n.show()
time.sleep(20)
If you liked the script then do share it ;)