prabhasha2006 / cricketlive

Get live cricket match data.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool



CricketLive

GitHub stars GitHub forks GitHub views npm Creator



cricketlive is a Node.js module that scrapes cricket match details from a given URL using axios and cheerio. This module was created by Evelocore.



Table of Contents




Features


  • Fetches live cricket scores from ESPN Cricinfo
  • Provides detailed match information including team scores, overs, and match status
  • Easy to integrate with Node.js projects


Installation


  • Before using this module, it is required to download NodeJS from nodejs.org.
  • To install the module, use npm:

npm i cricketlive


Usage


Here’s how to use the cricketlive module in your project:

// Import cricket live module
const { cricketlive } = require('cricketlive')

// Get The URL Of The Cricket Match From espncricinfo.com 
// NOTE* - THE URL MUST END WITH THE PATH /live-cricket-score (Get the URL by going into summary section of the Match).

const url = 'https://www.espncricinfo.com/series/icc-men-s-t20-world-cup-2024-1411166/nepal-vs-netherlands-7th-match-group-d-1415707/live-cricket-score'
// replace with actual match URL

cricketlive(url).then(details => {
    console.log(details)
}).catch(error => {
    console.error(error)
})


Example Data


Here is an example of the data returned by the cricketlive function:

{
  "battingTeam": "Netherlands",
  "battingTeamOversAndTarget": "(18.4/20 ov, T:107) 109/4",
  "teamScores": { "Nepal": "106", "Netherlands": "109/4" },
  "matchStatus": "Netherlands won by 6 wickets (with 8 balls remaining)",
  "matchIsStarted": true,
  "matchIsEnd": true,
  "matchInBreak": false
}


API


Parameters

  • url (string): The URL of the cricket match details page to scrape.

Returns

  • A promise that resolves to an object containing the match details:

{
  "battingTeam": "Team Name",
  "battingTeamOversAndTarget": "20 ov, target 150",
  "teamScores": {
    "Team Name 1": "150/5",
    "Team Name 2": "145/9"
  },
  "matchStatus": "Team Name won by 5 runs",
  "matchIsStarted": true,
  "matchIsEnd": true,
  "matchInBreak": false
}


Errors


  • If there is an error fetching or parsing the data, the promise will be rejected with an error message.


Changelog

  • [2024.06.05] - Initial release - v1.0.0


License

MIT


About

Get live cricket match data.

License:MIT License


Languages

Language:JavaScript 100.0%