parser

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2025 License: MIT Imports: 11 Imported by: 0

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

func FetchLatestResultsYear(initialUrl string) (string, error)

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:

  1. The link's text is a 4-digit number (e.g., between 1950 and current year + buffer for future).
  2. 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

func ParseDriver() []model.Driver

ParseDriver Parse the driver standing info from formula1 website

func ParseRace

func ParseRace() []model.Race

ParseRace Parse the F1 race info from formula1 website

func ParseTeam

func ParseTeam() []model.Team

ParseTeam Parse the constructor standing info from formula1 website

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL