I have a list [ ] with dates, saved as strings (2020-12-01 to 2020-12-31). I also have the following url:
"https://api.opap.gr/draws/v3.0/1100/draw-date/{date1:%Y-%m-%d}/{date1:%Y-%m-%d}/draw-id"
I want to run a "for loop" in which it will replaces the {date1:%Y-%m-%d} for every element (date) of the list. So far, I have created the following code which creates "ValueError: Invalid format specifier".
from datetime import date, timedelta, datetime
import json, requests
def days_cur_month():
d1 = date(2020, 12, 1)
d2 = date(2020, 12, 31)
delta = d2 - d1
return [(d1 + timedelta(days=i)).strftime('%Y-%m-%d') for i in range(delta.days + 1)]
print(days_cur_month())
fmt= "https://api.opap.gr/draws/v3.0/1100/draw-date/{date1:%Y-%m-%d}/{date1:%Y-%m-%d}/draw-id"
draws=[]
for i in (days_cur_month()):
url = fmt.format(date1=i)
r=requests.get(url2)
html=r.text
drawIds=json.loads(html)
print(drawIds)
Is there any way to do this?