Last active
January 5, 2022 05:32
-
-
Save puhitaku/902f640ef12764b61a8480efbab828de to your computer and use it in GitHub Desktop.
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 | |
import requests | |
last = None | |
while True: | |
try: | |
res = requests.get('https://jp.sharp/edictionary/') | |
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