API reference
KrogocoIcs fetches a calendar page and builds the
ICS data. Each scraped entry is a CalendarEvent,
which you get from scrape_events() if you
want the events without the ICS step.
- class krogoco_calendar.KrogocoIcs(url, months, blacklist=None)[source]
Screen scrapes Krog & Co’s calendar page and produces ICS output.
The scraper walks the
<h3>elements on the calendar page, which follow this structure:Month headers (e.g.
"februari")Date lines (e.g.
"torsdag 05/02")Event links (
<a href="...">Event Title</a>)
Year rollover is detected automatically when the month number decreases (e.g. December → January).
- Parameters:
Example usage:
scraper = KrogocoIcs( url="https://krogoco.se/jonkoping/kalender/", months=2, blacklist=["HV71", "SHL"], ) scraper.write_ics("calendar.ics")
- BASE_URL = 'https://krogoco.se'
Base URL used to resolve relative event links.
- scrape_events()[source]
Scrape the calendar page and return a list of events.
Parses the
<h3>element structure of the calendar page, extracting dates and event links. Events in the past and events beyond the configuredmonthshorizon are excluded. Events matching theblacklistare also skipped.- Returns:
A list of
CalendarEventinstances in chronological order.- Return type:
- class krogoco_calendar.CalendarEvent(date, title, url, all_day=True, start_time=None, end_time=None)[source]
A single scraped calendar event.
- Parameters:
date (date) – The date of the event.
title (str) – The display title of the event.
url (str) – The full URL to the event detail page.
all_day (bool) –
Trueif the event has no specific start/end time.start_time (str | None) – Start time as
"HH:MM"string, orNonefor all-day events.end_time (str | None) – End time as
"HH:MM"string, orNoneif unknown.