fix: URL with no schema will raise error
This commit is contained in:
parent
7e43162920
commit
2f6c877493
@ -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)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user