tools/web: add a URL normalizer function
This commit is contained in:
parent
7102e08000
commit
20105e7d98
3 changed files with 15 additions and 16 deletions
|
|
@ -10,8 +10,6 @@ def isup(url):
|
|||
"""
|
||||
|
||||
o = urllib.parse.urlparse(url, "http")
|
||||
if o.netloc == "":
|
||||
o = urllib.parse.urlparse("http://" + url)
|
||||
if o.netloc != "":
|
||||
isup = getJSON("http://isitup.org/%s.json" % o.netloc)
|
||||
if isup is not None and "status_code" in isup and isup["status_code"] == 1:
|
||||
|
|
|
|||
|
|
@ -13,9 +13,7 @@ def validator(url):
|
|||
|
||||
o = urllib.parse.urlparse(url, "http")
|
||||
if o.netloc == "":
|
||||
o = urllib.parse.urlparse("http://" + url)
|
||||
if o.netloc == "":
|
||||
raise IRCException("Indiquer une URL valide !")
|
||||
raise IRCException("Indicate a valid URL!")
|
||||
|
||||
try:
|
||||
req = urllib.request.Request("http://validator.w3.org/check?uri=%s&output=json" % (urllib.parse.quote(o.geturl())), headers={ 'User-Agent' : "Nemubot v%s" % __version__})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue