A simple PHP-based API that fetches live cricket scores from Cricbuzz URLs. π―
- π Web interface for easy score retrieval
- π JSON API endpoint
- β URL validation
β οΈ Error handling- π Live score extraction from Cricbuzz pages
- π§ PHP 7.0 or higher
- π¦ DOM and libxml PHP extensions
- Access the root URL without parameters to view the web interface
- Enter a valid Cricbuzz URL in the input field
- Click "Get Score" to fetch the live score
Make a GET request with the url
parameter:
GET /?url=https://www.cricbuzz.com/live-cricket-scores/[match-id]
Success Response:
{
"status": "success",
"message": "Current Score",
"data": "Team A 100/2 (15.2 Ov)"
}
Error Response:
{
"status": "error",
"message": "Error description"
}
- "Invalid URL format" - The provided URL is not properly formatted
- "Failed to retrieve data from the source" - Unable to fetch data from Cricbuzz
- "Score card not found" - Unable to locate score information on the page
- π‘οΈ URL validation using
filter_var()
- π¨ JSON content-type headers
- π§Ή Input sanitization
- π Depends on Cricbuzz's HTML structure
β οΈ May break if Cricbuzz changes their page layout- πΎ No caching mechanism implemented