Skip to main content

Public holidays in Spain from 2006 to now

Project description

A small Python package to obtain the public holidays in Spain from 2006 to the current year. This application uses the web scraping technique to obtain the data from calendarioslaborales.net

Made with Python with ❤️

Package:
Python supported versions PyPI version Downloads
CI/CD:
https://github.com/rsolanodev/holidays-es/actions/workflows/action-push-develop.yml/badge.svg
Meta:
Code style License

Install

Install via pip:

$ pip install holidays-es

Quick Start

  1. Import the HolidaySpain class and set the province and year of the holidays you want to obtain.

from datetime import date
from holidays_es import Province, HolidaySpain, Scope

holiday_spain = HolidaySpain(province=Province.VALENCIA, year=2022)

holiday_date = date(day=1, month=1, year=2022)
expected_holiday = models.Holiday(
    scope=Scope.NATIONAL,
    date=holiday_date,
    description="Año nuevo",
)

assert expected_holiday == holiday_spain.find(date=holiday_date)
  1. If you only need the national, regional, or local holidays, you can also obtain them in the following way:

from holidays_es import Province, HolidaySpain

holiday_spain = HolidaySpain(province=Province.MADRID, year=2020)

for holiday in holiday_spain.national:
    holiday.scope  # <Scope.NATIONAL: 'national'>
    holiday.date  # datetime.date(2023, 1, 1)
    holiday.description  # Año nuevo

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

holidays_es-2.0.0.tar.gz (5.4 kB view hashes)

Uploaded Source

Built Distribution

holidays_es-2.0.0-py3-none-any.whl (6.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page