[networking] use getJSON
This commit is contained in:
parent
86fdaa4dd9
commit
a1c086a807
2 changed files with 4 additions and 15 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import json
|
||||
import urllib
|
||||
|
||||
from tools.web import getJSON
|
||||
|
||||
def isup(url):
|
||||
"""Determine if the given URL is up or not
|
||||
|
|
@ -13,9 +13,7 @@ def isup(url):
|
|||
if o.netloc == "":
|
||||
o = urllib.parse.urlparse("http://" + url)
|
||||
if o.netloc != "":
|
||||
req = urllib.request.Request("http://isitup.org/%s.json" % (o.netloc), headers={ 'User-Agent' : "nemubot v3" })
|
||||
raw = urllib.request.urlopen(req, timeout=10)
|
||||
isup = json.loads(raw.read().decode())
|
||||
isup = getJSON("http://isitup.org/%s.json" % o.netloc)
|
||||
if "status_code" in isup and isup["status_code"] == 1:
|
||||
return isup["response_time"]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue