krogoco-calendar documentation
- Author:
Jonny Bergdahl
- Version:
1.0.0
krogoco-calendar
A Python library that scrapes Krog&Co calendar pages and converts them to iCalendar (ICS) files.
Full documentation: https://jonnybergdahl.github.io/krogoco-calendar/
Installation
pip install krogoco-calendar
Python 3.10 or newer is required.
For development, clone the repository and install locally:
git clone https://github.com/jonnybergdahl/Python-krogoco-calendar.git
cd Python-krogoco-calendar
pip install -e ".[dev]"
Usage
from krogoco_calendar import KrogocoIcs
scraper = KrogocoIcs(
url="https://krogoco.se/jonkoping/kalender/",
months=2,
)
# Get ICS as a string
ics_data = scraper.get_ics()
# Or write directly to a file
scraper.write_ics("krogoco.ics")
Blacklist
You can filter out events by providing a blacklist of keywords. Events whose title contains any of the keywords (case-insensitive) will be excluded:
scraper = KrogocoIcs(
url="https://krogoco.se/jonkoping/kalender/",
months=2,
blacklist=["HV71", "SHL", "match"],
)
Supported locations
The library works with any Krog & Co location that uses the same calendar page structure:
https://krogoco.se/jonkoping/kalender/https://krogoco.se/halmstad/kalender/
Time format handling
Event times are extracted automatically from Swedish title formats:
Format |
Example |
Parsed as |
|---|---|---|
Full range |
|
12:00 - 16:00 |
Short range |
|
12:00 - 17:00 |
Bare hour range |
|
22:00 - 03:00 (next day) |
Single time |
|
17:00 / 21:00 |
Time with hint |
|
22:00 - 23:00 |
No time |
|
All-day event |
Running tests
pytest
Publishing
build.sh runs the tests, builds the docs and pushes them to
jonnybergdahl.github.io,
then builds the package and uploads it to PyPI. Bump __version__ in
src/krogoco_calendar/__init__.py first.
License
MIT
API reference