Advertisement
Sandbird

Untitled

Apr 21st, 2023
785
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.98 KB | Source Code | 0 0
  1. #pip install pushbullet.py
  2.  
  3. import requests
  4. import hashlib
  5. import time
  6. import pushbullet
  7.  
  8. def check_data_file(url):
  9.     response = requests.get(url)
  10.     content_hash = hashlib.md5(response.content).hexdigest()
  11.     return content_hash
  12.  
  13. # Set the URL of the CSV file
  14. url = "https://opendata.ecdc.europa.eu/covid19/nationalcasedeath/csv/data.csv"
  15.  
  16. # Set the interval for checking updates (in seconds)
  17. interval = 3600
  18.  
  19. # Set your Pushbullet API key and target device ID
  20. pb = pushbullet.Pushbullet("x.XXXXXXXXXXXXXXXXXXXXXXXXXXXX")
  21.  
  22. # Initial hash value
  23. last_hash = check_data_file(url)
  24.  
  25. while True:
  26.     current_hash = check_data_file(url)
  27.     if current_hash != last_hash:
  28.         print("The data file has been updated!")
  29.         # Send a push notification using Pushbullet
  30.         pb.push_note("Data file updated", "The COVID-19 data file has been updated!")
  31.         last_hash = current_hash
  32.     print("Next cycle starting in", interval, "seconds…")
  33.     time.sleep(interval)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement