Skip to content
Snippets Groups Projects
Commit bef95762 authored by Svetlana Tkachenko's avatar Svetlana Tkachenko
Browse files

Send version headers with urllib for isitup to work

parent b40ea545
No related branches found
No related tags found
No related merge requests found
......@@ -36,7 +36,7 @@ import time
class main(object):
def __init__(self):
# Constant.
self.version = "0.4.3"
self.version = "0.4.4"
self.homedir = os.path.abspath(os.path.dirname(__file__))
print(" __ _ _ _ _ __ _ __ _ _ ")
print(" / _` | | | | '_ \| '_ \| | | | http://repo.or.cz/w/guppy.git/summary")
......
......@@ -19,7 +19,9 @@
# MA 02110-1301, USA.
import urllib.request, urllib.parse, urllib.error, json
#import urllib.request, urllib.parse, urllib.error, json
from urllib.request import Request, urlopen
import json
@plugin
......@@ -42,10 +44,10 @@ class IsItUp(object):
url = args[0][8:]
else:
url = args[0]
code = "".join(x.decode('utf8') for x in urllib.request.urlopen("http://isitup.org/" +
url + ".json").readlines())
#code = code.decode('utf8')
print(code)
url = "http://isitup.org/" +url + ".json"
req = Request(url,headers={'User-Agent': 'guppy/'+self.server.config["version"]})
code = "".join(urlopen(req).read().decode('utf8'))
# print(code)
arr = json.loads(code)
arr['up'] = 'up' if arr['status_code'] == 1 else 'not up'
if arr['up'] == 'up':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment