Feed date scraper for Gemini (protocol)
gemini request: wrap more in try block
| -rwxr-xr-x | zachwalk.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/zachwalk.py b/zachwalk.py index 0e5feb6..6da89c4 100755 --- a/zachwalk.py +++ b/zachwalk.py @@ -15,14 +15,14 @@ def getnewestdate(url): hostname = url.split('/')[2] try: s = socket.create_connection((hostname, 1965),timeout=2) + context = ssl.SSLContext() + context.check_hostname = False + context.verify_mode = ssl.CERT_NONE + s = context.wrap_socket(s, server_hostname = hostname) + s.sendall((url + '\r\n').encode("UTF-8")) + fp = s.makefile("rb") except: return DEFAULT - context = ssl.SSLContext() - context.check_hostname = False - context.verify_mode = ssl.CERT_NONE - s = context.wrap_socket(s, server_hostname = hostname) - s.sendall((url + '\r\n').encode("UTF-8")) - fp = s.makefile("rb") header = fp.readline() header = header.decode("UTF-8").strip() # TODO: something special if status is not 2x |