fix streambtw.py scraping
This commit is contained in:
doms9 2026-02-05 20:11:19 -05:00
parent bbd702e60a
commit 00000d9f74

View file

@ -15,7 +15,7 @@ TAG = "STRMBTW"
CACHE_FILE = Cache(TAG, exp=3_600) CACHE_FILE = Cache(TAG, exp=3_600)
BASE_URL = "https://hiteasport.info/" BASE_URL = "https://hiteasport.info"
def fix_league(s: str) -> str: def fix_league(s: str) -> str:
@ -53,29 +53,28 @@ async def get_events() -> list[dict[str, str]]:
soup = HTMLParser(html_data.content) soup = HTMLParser(html_data.content)
for event in soup.css(".t-item"): for card in soup.css(".league"):
if not (league_elem := event.css_first(".t-league")): if not (league_elem := card.css_first(".league-title")):
continue continue
if not (event_elem := event.css_first(".t-match")): for event in card.css(".match"):
continue if not (match_elem := event.css_first(".match-name")):
continue
if not (watch_btn := event.css_first("a.t-watch")) or not ( if (not (watch_btn := event.css_first("a.watch-btn"))) or (
href := watch_btn.attributes.get("href") not (href := watch_btn.attributes.get("href"))
): ):
continue continue
league = league_elem.text(strip=True) league, name = league_elem.text(strip=True), match_elem.text(strip=True)
event = event_elem.text(strip=True) events.append(
{
events.append( "sport": fix_league(league),
{ "event": name,
"sport": fix_league(league), "link": urljoin(BASE_URL, href),
"event": event, }
"link": urljoin(BASE_URL, href), )
}
)
return events return events