Feed date scraper for Gemini (protocol)
getnewestdate: split into a tustable segment
| -rwxr-xr-x | zachwalk.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/zachwalk.py b/zachwalk.py index 9584cef..7965962 100755 --- a/zachwalk.py +++ b/zachwalk.py @@ -6,6 +6,8 @@ import socket import ssl from dateutil.parser import parse +DEFAULT = '1970-01-01' + def getnewestdate(url): """load the url, and find the newest date listed in a link""" # TODO: outsource to pre-installed cli program? @@ -21,6 +23,8 @@ def getnewestdate(url): header = fp.readline() header = header.decode("UTF-8").strip() # TODO: something special if status is not 2x + return gnd(fp) +def gnd(fp): for line in fp: line=line.decode('UTF-8') if line.strip()[0:2] == '=>': @@ -30,7 +34,7 @@ def getnewestdate(url): return date except: pass - return '1970-01-01' + return DEFAULT def main(argv): with open(argv[1]) as f: |