Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -32,31 +32,37 @@ def get_match_links_from_main_page():
|
|
| 32 |
|
| 33 |
soup = BeautifulSoup(response.text, "html.parser")
|
| 34 |
|
| 35 |
-
links = []
|
| 36 |
all_a_tags = soup.find_all("a", href=True)
|
| 37 |
-
print(f"π [CRAWL] Total <a> tags found: {len(all_a_tags)}
|
| 38 |
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
|
|
|
| 42 |
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
print(f" HREF: {href}\n")
|
| 46 |
|
| 47 |
-
#
|
| 48 |
-
if "
|
|
|
|
|
|
|
| 49 |
full_url = BASE_URL + href
|
| 50 |
-
print(f"
|
| 51 |
-
|
|
|
|
|
|
|
| 52 |
|
| 53 |
-
|
|
|
|
|
|
|
| 54 |
return links
|
| 55 |
|
| 56 |
except Exception as e:
|
| 57 |
print(f"β [CRAWL ERROR] Failed to fetch match links: {e}")
|
| 58 |
return []
|
| 59 |
|
|
|
|
| 60 |
# --- Crawl each link and extract score ---
|
| 61 |
def get_scores_from_links(team_name=None):
|
| 62 |
print("π‘ [STEP 1] Start crawling for scores...")
|
|
|
|
| 32 |
|
| 33 |
soup = BeautifulSoup(response.text, "html.parser")
|
| 34 |
|
|
|
|
| 35 |
all_a_tags = soup.find_all("a", href=True)
|
| 36 |
+
print(f"π [CRAWL] Total <a> tags found: {len(all_a_tags)}")
|
| 37 |
|
| 38 |
+
links = []
|
| 39 |
+
for i in range(len(all_a_tags) - 1):
|
| 40 |
+
tag = all_a_tags[i]
|
| 41 |
+
next_tag = all_a_tags[i + 1]
|
| 42 |
|
| 43 |
+
text = tag.get_text().strip()
|
| 44 |
+
href = tag['href']
|
|
|
|
| 45 |
|
| 46 |
+
# Looking for IPL match result + scorecard links
|
| 47 |
+
if "cricket-scores" in href and any(team.lower() in text.lower() for team in IPL_TEAMS):
|
| 48 |
+
title = text
|
| 49 |
+
result = next_tag.get_text().strip()
|
| 50 |
full_url = BASE_URL + href
|
| 51 |
+
print(f"\nπ― [MATCH FOUND]")
|
| 52 |
+
print(f"π·οΈ Title: {title}")
|
| 53 |
+
print(f"π Result: {result}")
|
| 54 |
+
print(f"π Link: {full_url}")
|
| 55 |
|
| 56 |
+
links.append((f"{title} β {result}", full_url))
|
| 57 |
+
|
| 58 |
+
print(f"\nβ
[DONE] Total match results extracted: {len(links)}")
|
| 59 |
return links
|
| 60 |
|
| 61 |
except Exception as e:
|
| 62 |
print(f"β [CRAWL ERROR] Failed to fetch match links: {e}")
|
| 63 |
return []
|
| 64 |
|
| 65 |
+
|
| 66 |
# --- Crawl each link and extract score ---
|
| 67 |
def get_scores_from_links(team_name=None):
|
| 68 |
print("π‘ [STEP 1] Start crawling for scores...")
|