В результате я получаю 404. p>
Точно не знаю, чего не нашел
Код: Выделить всё
from datetime import datetime
import requests, json
# Cron-job.org API URL
api_url = "https://cron-job.org/api/1.0/user/cronjobs"
# api_url = "https://api.cron-job.org"
# Your cron-job.org API key
api_key = "*******************************************"
# Cron job details
command_url = f"https://httpbin.org/json"
# Extract hour and minute
try:
hour = 10
minute = 30
# Prepare cron job schedule (cron-job.org takes time in hour and minute, not the standard cron format)
schedule = {
"minute": minute,
"hour": hour,
"mdays": ["*"], # Every day of the month
"months": ["*"], # Every month
"wdays": ["*"], # Every day of the week
"enabled": True,
"url": command_url
}
# Create headers with API key for authentication
headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"}
# Make the API request to create the cron job
response = requests.post(api_url, headers=headers, data=json.dumps(
schedule))
# Check if the cron job was created successfully
if response.status_code == 201:
print("Cron job created successfully.")
else:
print(f"Failed to create cron job: {response}")
print(response.text)
except Exception as e:
print(f'Errrrrrror: {e}')
Подробнее здесь: https://stackoverflow.com/questions/792 ... ob-org-api
Мобильная версия