timmy / 台灣假日 API 查詢與快取
0 вподобань
0 форк(-ів)
1 файл(-ів)
Остання активність 10 months ago
這段程式碼是一個節假日查詢工具,從指定 API 獲取節假日資料,支援緩存與分頁,並提供按年份篩選節假日、檢查特定日期是否為節假日的功能,同時以 Holiday 類別封裝每個節假日的詳細資訊,便於操作與顯示。
| 1 | import requests |
| 2 | import os |
| 3 | import json |
| 4 | |
| 5 | class HolidayAPI: |
| 6 | def __init__(self, base_url, cache_dir="cache"): |
| 7 | """ |
| 8 | Initialize the HolidayAPI class. |
| 9 | :param base_url: The base URL for the API endpoint. |
| 10 | :param cache_dir: Directory to store cached data. |
Новіше
Пізніше