Skip to content

Instantly share code, notes, and snippets.

@vik-y
Created March 20, 2016 16:34
Show Gist options
  • Save vik-y/7f302932de742abaaf01 to your computer and use it in GitHub Desktop.
Save vik-y/7f302932de742abaaf01 to your computer and use it in GitHub Desktop.
Script to get Live score from cricbuzz website.
import time
import re
headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'}
def cleanhtml(raw_html):
cleanr =re.compile('<.*?>')
cleantext = re.sub(cleanr,'', raw_html)
return cleantext
def liveScore():
data = requests.get('http://push.cricbuzz.com/match-push?id=15788', headers=headers)
# Just replace id=15788 with the match id and it will work for any cricket match.
#print data
game = json.loads(data.text)
retData = ""
retData += game['score']['batting']['score']
retData += "\n"
try:
comment = cleanhtml(game['comm_lines'][0]['comm'])
except:
comment = ""
retData += comment + "\n"
return retData
print liveScore()
@sanket08
Copy link

sanket08 commented Apr 9, 2018

how to use it plz tell me.

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