cricketlive
Version:
Get live cricket match details.
170 lines (126 loc) • 3.81 kB
Markdown
<br><br>
<p align="center">
<img width="140" src="https://i.ibb.co/9bWQGVP/image.png">
</p>
<h1 align="center">CricketLive</h1>
<div align="center">




[](https://github.com/prabhasha2006)
</div>
<hr>
<br>
<h3 align="center">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.</h3>
<br>
<hr>
<br>
- [Features](
- [Installation](
- [Usage](
- [Example Data](
- [API](
- [Errors](
- [Prerequisites](
- [Configuration](
- [Testing](
- [Changelog](
- [FAQ](
- [Credits](
- [Special Thanks](
- [Contributing](
- [License](
<br>
<hr>
<br>
- 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
<br>
<hr>
<br>
- Before using this module, it is required to download NodeJS from [nodejs.org](https://nodejs.org).
- To install the module, use [npm](https://www.npmjs.com/package/cricketlive):
<br>
```bash
npm i cricketlive
```
<br>
<hr>
<br>
Here’s how to use the cricketlive module in your project:
<br><br>
```javascript
// 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)
})
```
<br>
<hr>
<br>
Here is an example of the data returned by the cricketlive function:
<br><br>
```bash
{
"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
}
```
<br>
<hr>
<br>
<b> Parameters </b>
<br>
- <b>url</b> `(string)`: The URL of the cricket match details page to scrape.
<b> Returns </b>
<br>
- A `promise` that resolves to an object containing the match details:
<br>
```bash
{
"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
}
```
<br>
<hr>
<br>
- If there is an error fetching or parsing the data, the promise will be rejected with an error message.
<br>
<hr>
- <b>[2024.06.05]</b> - <font color="aqua">Initial release</font> - `v1.0.0`
<br>
<hr>
[](https://choosealicense.com/licenses/mit/)
<hr>