From 2f6c8774931c49349846f24f274275095dabe5e6 Mon Sep 17 00:00:00 2001 From: Maks Snegov Date: Sun, 15 Jun 2014 20:16:35 +0400 Subject: [PATCH] fix: URL with no schema will raise error --- nevernote.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nevernote.py b/nevernote.py index c805ad2..a240297 100755 --- a/nevernote.py +++ b/nevernote.py @@ -18,6 +18,8 @@ def get_page(url): charset = 'utf-8' up = urlparse(url) + if not up.scheme: + up = urlparse('http://' + url) headers = { "Host": up.netloc, @@ -30,7 +32,7 @@ def get_page(url): elif up.scheme == 'https': conn = http.client.HTTPSConnection(up.netloc) else: - print("ERROR: invalid protocol set in '{0}'".format(url)) + raise NotImplementedError("protocol %s is not implemented" % up.scheme) return False conn.request("GET", up.path, None, headers)