tools/web: add a URL normalizer function

This commit is contained in:
nemunaire 2015-10-11 17:04:21 +02:00
commit 20105e7d98
3 changed files with 15 additions and 16 deletions

View file

@ -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:

View file

@ -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__})