TL;DR
from io import StringIO
import urllib.request
import pandas as pd
req = urllib.request.Request('https://holidays-jp.github.io/api/v1/date.csv')
with urllib.request.urlopen(req) as res:
df_holiday = pd.read_csv(StringIO(res.read().decode()), header=None)
req = urllib.request.Request('https://holidays-jp.github.io/api/v1/date.csv')
Simple Izu Vest
with urllib.request.urlopen(req) as res:
df_holiday = pd.read_csv(StringIO(res.read().decode()), header=None)
Since the request data is binary data, it is converted to string by the decode function, and the input is sent to the read_csv function using StringIO.
This method is for making it simple. If you want more detailed holiday data, you may be happy with the jpholiday
library.
--Urllib.request is sufficient for Python HTTP client
Recommended Posts