- edit scraping for ovogoal.py
- misc edits.
This commit is contained in:
doms9 2026-04-11 11:40:47 -04:00
parent 6bd8aa9814
commit 00000d905b
4 changed files with 23 additions and 29 deletions

View file

@ -76,7 +76,7 @@ async def get_events(cached_hrefs: set[str]) -> list[dict[str, str]]:
{
"sport": sport,
"event": clean_event.sub("", event_name),
"link": urljoin(BASE_URL, href),
"link": urljoin(f"{html_data.url}", href),
"href": href,
}
)

View file

@ -1,5 +1,6 @@
import re
from functools import partial
from urllib.parse import urljoin
from selectolax.parser import HTMLParser
@ -16,10 +17,6 @@ CACHE_FILE = Cache(TAG, exp=28_800)
BASE_URL = "https://ovogoaal.com"
def fix_league(s: str) -> str:
return " ".join(x.capitalize() for x in s.split()) if len(s) > 5 else s.upper()
async def process_event(url: str, url_num: int) -> tuple[str | None, str | None]:
nones = None, None
@ -64,34 +61,31 @@ async def get_events(cached_keys: list[str]) -> list[dict[str, str]]:
soup = HTMLParser(html_data.content)
sport = None
sport = "Live Event"
for node in soup.css(".wrapper *"):
if (cls := node.attributes.get("class")) == "section-title":
sport = fix_league(node.text(strip=True))
for card in soup.css(".main-content .stream-row"):
if (not (watch_btn_elem := card.css_first(".watch-btn"))) or (
not (onclick := watch_btn_elem.attributes.get("onclick"))
):
continue
if node.tag == "a" and cls == "match":
if not sport:
continue
if not (event_name_elem := card.css_first(".stream-info")):
continue
if not (team_elems := node.css(".team")):
continue
href = onclick.split(".href=")[-1].replace("'", "")
if not (href := node.attributes.get("href")):
continue
event_name = event_name_elem.text(strip=True)
event_name = " vs ".join(team.text(strip=True) for team in team_elems)
if f"[{sport}] {event_name} ({TAG})" in cached_keys:
continue
if f"[{sport}] {event_name} ({TAG})" in cached_keys:
continue
events.append(
{
"sport": sport,
"event": event_name,
"link": href,
}
)
events.append(
{
"sport": sport,
"event": event_name,
"link": urljoin(f"{html_data.url}", href),
}
)
return events

View file

@ -113,7 +113,7 @@ async def get_events(cached_keys: list[str]) -> list[dict[str, str]]:
{
"sport": sport,
"event": event_name,
"link": urljoin(BASE_URL, href),
"link": urljoin(f"{html_data.url}", href),
}
)

View file

@ -66,7 +66,7 @@ async def get_events() -> list[dict[str, str]]:
{
"sport": sport,
"event": event_name,
"link": urljoin(BASE_URL, href),
"link": urljoin(f"{html_data.url}", href),
}
)