Documentation
¶
Overview ¶
Copyright © 2022 Yusuf DÜNDAR <info@dundar.dev>
Parser for the formula1 official website
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FetchLatestResultsYear ¶ added in v0.2.0
fetchLatestResultsYear fetches the HTML from initialUrl, parses it to find available result years, and returns the most recent year that is less than or equal to the current real-world year.
The year selection logic primarily targets <a> tags within common filter component structures often found on websites for selecting seasons or years.
Attempt 1 (Targeted): It first looks for <a> tags with href attributes containing "/en/results.html/" and validates if the link's text is a 4-digit year that also appears in the href. Example: <a href="/en/results.html/2024/drivers.html">2024</a>
Attempt 2 (Broad Search - Fallback): If the targeted search yields no years, it iterates through ALL <a> tags. For each link, it logs its text and href for debugging purposes. It then validates if:
- The link's text is a 4-digit number (e.g., between 1950 and current year + buffer for future).
- The link's `href` attribute exists and contains "/results.html/" + the found year string + "/".
This broad search helps identify potential year links even if their structure deviates significantly.
The function sorts all unique, validated years in descending order and returns the first one that is less than or equal to the current real-world year (obtained via `time.Now().Year()`). If no such year is found, or if fetching/parsing fails, an error is returned.
func ParseDriver ¶
ParseDriver Parse the driver standing info from formula1 website
Types ¶
This section is empty.