commit 6b45d6273f231b956f9387b785247a8792eadd83 Author: Anastasiya Date: Fri Feb 23 20:24:59 2024 +0500 первый код diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..c1ab817 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..057741d --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/polka.iml b/.idea/polka.iml new file mode 100644 index 0000000..74d515a --- /dev/null +++ b/.idea/polka.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..a24ef47 --- /dev/null +++ b/main.py @@ -0,0 +1,32 @@ +import requests +import time +from datetime import datetime + + +def main(): + while True: + current_time = datetime.now().strftime("%H:%M") + if "21:00" <= current_time < "09:00": + url = "http://192.168.89.21/api/radio?receive=3&comand_id=9&comand=2&metrika=0" + elif "09:00" <= current_time < "21:00": + url = "http://192.168.89.21/api/radio?receive=3&comand_id=9&comand=1&metrika=0" + else: + # If the current time doesn't fall within the defined ranges, sleep for a minute and then check again + time.sleep(60) + continue + + try: + response = requests.get(url) + if response.status_code == 200: + print(f"Результат запроса ({current_time}):", response.text) + else: + print(f"Ошибка при запросе ({current_time}). Код состояния:", response.status_code) + except requests.RequestException as e: + print(f"Ошибка при выполнении запроса ({current_time}):", e) + + # После выполнения запроса ожидаем минуту перед повторной проверкой времени + time.sleep(60) + + +if __name__ == "__main__": + main()