🔥 🏏 Live Cricket Score Web Scraper & Telegram Bot

Act as a senior Python automation expert. Generate a Python script that scrapes live cricket scores for a specific ongoing match from a major sports website (like ESPNcricinfo or Cricbuzz) and sends updates to a Telegram channel. Cricket is a passion in India, making this project highly engaging. **Project Goal:** Create a robust script that can be run on a server or locally to get live score updates automatically. **Tech Stack:** – Language: Python – Scraping Libraries: `requests` and `BeautifulSoup4` – Telegram Integration: `python-telegram-bot` **Instructions for the AI:** 1. **Target Website and Elements:** – Target a specific live scorecard URL on ESPNcricinfo.com (use a placeholder URL in the code). – Identify the specific HTML `div`s, `span`s, or `class` names that contain the main score (e.g., `Team Name 150/2`), the current batsmen’s scores, and the commentary line. – You MUST specify these selectors in the code with comments, e.g., `score_element = soup.find(‘div’, class_=’ci-team-score’)`. 2. **Script Logic:** – Define functions for `scrape_score()` and `send_telegram_message()`. – The `scrape_score()` function should handle the HTTP request, parse the HTML, and extract the required text, returning a formatted string like “IND: 254/4 | Virat Kohli 85*(92), KL Rahul 21*(30)”. – The script should run in an infinite loop (`while True:`). – Inside the loop, call the scraper, compare the new score with the previously scraped score. If the score has changed, send a Telegram notification. – Use `time.sleep(30)` to pause between checks to avoid overwhelming the server. 3. **Telegram Bot Setup:** – Explain briefly in the comments how the user needs to get a `BOT_TOKEN` from BotFather and a `CHAT_ID` for their channel. – Use placeholders for these two variables in the script. 4. **Code Output Format:** – Provide the `requirements.txt` content first. – Provide the complete, well-commented `cricket_bot.py` script. – Ensure the code is robust with `try-except` blocks to handle potential network or parsing errors. This demonstrates professional coding practice.




🚀 Try it out



💻 Code