Created
March 6, 2023 12:10
-
-
Save puhitaku/5370650ffde9be4e53643359fba4a075 to your computer and use it in GitHub Desktop.
HKSNEIDN watcher
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
from datetime import datetime | |
from email.utils import parsedate | |
# pip install requests | |
import requests | |
last = None | |
while True: | |
try: | |
res = requests.get('https://www.hokushin-eiden.co.jp/') | |
except: | |
res = None | |
if res is None or res.status_code != 200: | |
time.sleep(60) | |
continue | |
# https://stackoverflow.com/questions/1471987/how-do-i-parse-an-http-date-string-in-python | |
dt = datetime(*parsedate(res.headers['Last-Modified'])[:6]) | |
if last is None: | |
print(f'Last-Modified: {dt.isoformat()}') | |
print("I'll tell you when it's updated") | |
last = dt | |
elif last < dt: | |
print('UPDATED!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1') | |
print('UPDATED!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1') | |
print('UPDATED!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1') | |
print('UPDATED!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1') | |
print('UPDATED!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1') | |
print('UPDATED!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1') | |
print('UPDATED!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1') | |
print('UPDATED!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1') | |
last = dt | |
time.sleep(60) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment