[Python] Website monitor script stops working after a few hours?

Discussão em 'Python' iniciado por Stack, Março 26, 2025.

  1. Stack

    Stack Membro Participativo

    This is the script with sensitive information redacted. After a few hours, the python window is still open but it stops updating. The website updates but the script doesn't catch it. It immediately sees the update if I close and re-open the script.

    import time
    import os
    import yagmail
    import datetime
    import subprocess
    import subprocess, os, platform

    import requests
    from bs4 import BeautifulSoup
    import re
    from datetime import date

    monitoring_interval = 60

    today = date.today().day
    updated_time = ""

    while today != updated_time:
    page = requests.get(URL)
    soup = BeautifulSoup(page.content, "html.parser")

    updated_time = soup.findAll('div', class_=['left'])
    updated_time = [res.text for res in updated_time]
    updated_time = re.search(r"(?<=Last updated ).+(?=\n)", updated_time[0]).group()
    updated_time = datetime.datetime.strptime(updated_time, '%H:%M:%S %Y-%m-%d')
    updated_time = updated_time.day

    print("Change detected")

    time.sleep(999999)

    Continue reading...

Compartilhe esta Página