File size: 1,081 Bytes
fd7d2b3
 
16839c2
fd7d2b3
 
 
 
 
16839c2
fd7d2b3
 
 
 
16839c2
fd7d2b3
16839c2
fd7d2b3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import requests
from bs4 import BeautifulSoup

# Example: scrape live matches (ESPNCricinfo or Cricbuzz)
def list_live_matches():
    url = "https://www.espncricinfo.com/live-cricket-match-results"
    response = requests.get(url)
    soup = BeautifulSoup(response.text, "html.parser")

    matches = []
    for item in soup.select(".ds-px-4.ds-py-3"):
        title = item.get_text(" ", strip=True)
        matches.append(title)

    return matches


def scorecard(match_url: str):
    response = requests.get(match_url)
    soup = BeautifulSoup(response.text, "html.parser")

    # (MVP: extract only scores; later we can refine for player stats)
    score = soup.select_one(".ds-text-compact-xxs.ds-font-medium")
    return score.get_text(strip=True) if score else "No score found"


def extract_simple_context(match_url: str):
    # For MVP: return score only
    return scorecard(match_url)


def striker_form_last_overs(player_name: str):
    # Placeholder – later we’ll integrate CricAPI or Stats API
    return f"Recent form data for {player_name} (to be implemented)"