I want to create a script that run at a specific date everyday given the variable status as a parameter.
The status can take two entries: "past" or "present".
I want to save the current date as a parameter and use it after in a function to make different calls. So the current time becomes also a parameter.
For example, if I set the script to be running every day at 2:30 I want to be able to retrieve the date and use it as a parameter
I want to run the script with the status "present" with the day of today as a parameter and for the "past" for example, use the day of today minus 4 hours.
If my script is taking too long to run I want to use the date of today rounded to the last half hour.
So if I run my script the on the 8th of November 2022 at 5:32 I should get year=2022 month=11 day = 8 time =5:30 for the present and year=2022 month=11 day = 8 time =4:30 for the past
def function(past_or_present,year,month,day,time):
if past_or_present =="past":
url = 'https://awebsite{year}/{month}/{day}/{time-1hour}
resp = requests.get(url=url).text
if past_or_present =="present":
url = 'https://awebsite{year}/{month}/{day}/{time}
resp = requests.get(url=url).text
function("past")
function("present")