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'
|
charset = 'utf-8'
|
||||||
|
|
||||||
up = urlparse(url)
|
up = urlparse(url)
|
||||||
|
if not up.scheme:
|
||||||
|
up = urlparse('http://' + url)
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
"Host": up.netloc,
|
"Host": up.netloc,
|
||||||
@ -30,7 +32,7 @@ def get_page(url):
|
|||||||
elif up.scheme == 'https':
|
elif up.scheme == 'https':
|
||||||
conn = http.client.HTTPSConnection(up.netloc)
|
conn = http.client.HTTPSConnection(up.netloc)
|
||||||
else:
|
else:
|
||||||
print("ERROR: invalid protocol set in '{0}'".format(url))
|
raise NotImplementedError("protocol %s is not implemented" % up.scheme)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
conn.request("GET", up.path, None, headers)
|
conn.request("GET", up.path, None, headers)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user