Repository navigation
Expand file tree
/
Copy pathgatePLAY.py
More file actions
42 lines (35 loc) · 1.47 KB
/
Copy pathgatePLAY.py
File metadata and controls
42 lines (35 loc) · 1.47 KB
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
36
37
38
39
40
41
42
"""This script uses Playwright to scrape matchday dates from the Kicker website for/
the Bundesliga season 2025-26.
It collects the dates for each matchday and stores them in a cumulative list."""
from playwright.sync_api import Playwright, sync_playwright, expect
MD=28
TORNEO='2025-26'
lst_dates_cumul = []
def get_mdd_dates(mday, page):
"""create empty list to populate with dates"""
list_mdd_dates = []
page.goto(f'https://kicker.de/bundesliga/spieltag/{TORNEO}/{mday}', timeout=60000)
dates = page.locator(".kick__v100-gameList__header").all_inner_texts()
#dates = re.findall(r'\d{1,2}\.\s\w+\.\s\d{4}', date)
for date in dates:
date_formatted = date.split(" ")[1].strip()
#list_mdd_dates.append(date_formatted.strip())
list_mdd_dates.append(date_formatted)
return list_mdd_dates
def run(playwright: Playwright) -> None:
"""Main function to run the Playwright script"""
browser = playwright.chromium.launch(headless=False)
context = browser.new_context()
page = context.new_page()
page.goto("https://www.kicker.de/")
page.get_by_role("link", name="Zustimmen & weiter").click()
for i in range(1, MD+1):
list_mdd_dates = get_mdd_dates(i, page)
#lst_dates_cumul.append(list_mdd_dates[0])
lst_dates_cumul.extend(list_mdd_dates)
#print(sorted(set(lst_dates_cumul)))
# ---------------------
context.close()
browser.close()
with sync_playwright() as playwright:
run(playwright)