|
|
|
@ -199,7 +199,7 @@ def readFile(filename): |
|
|
|
|
fp.close() |
|
|
|
|
return fBody |
|
|
|
|
except Exception as e: |
|
|
|
|
# print(e) |
|
|
|
|
print(e) |
|
|
|
|
return False |
|
|
|
|
|
|
|
|
|
def writeFile(filename, content, mode='w+'): |
|
|
|
@ -764,6 +764,112 @@ def deDoubleCrypt(key, strings): |
|
|
|
|
writeFileLog(getTracebackInfo()) |
|
|
|
|
return strings |
|
|
|
|
|
|
|
|
|
# ------------------------------ network start ----------------------------- |
|
|
|
|
|
|
|
|
|
def HttpGet(url, timeout=10): |
|
|
|
|
""" |
|
|
|
|
发送GET请求 |
|
|
|
|
@url 被请求的URL地址(必需) |
|
|
|
|
@timeout 超时时间默认60秒 |
|
|
|
|
return string |
|
|
|
|
""" |
|
|
|
|
if sys.version_info[0] == 2: |
|
|
|
|
try: |
|
|
|
|
import urllib2 |
|
|
|
|
import ssl |
|
|
|
|
if sys.version_info[0] == 2: |
|
|
|
|
reload(urllib2) |
|
|
|
|
reload(ssl) |
|
|
|
|
try: |
|
|
|
|
ssl._create_default_https_context = ssl._create_unverified_context |
|
|
|
|
except: |
|
|
|
|
pass |
|
|
|
|
response = urllib2.urlopen(url, timeout=timeout) |
|
|
|
|
return response.read() |
|
|
|
|
except Exception as ex: |
|
|
|
|
return str(ex) |
|
|
|
|
else: |
|
|
|
|
try: |
|
|
|
|
import urllib.request |
|
|
|
|
import ssl |
|
|
|
|
try: |
|
|
|
|
ssl._create_default_https_context = ssl._create_unverified_context |
|
|
|
|
except: |
|
|
|
|
pass |
|
|
|
|
response = urllib.request.urlopen(url, timeout=timeout) |
|
|
|
|
result = response.read() |
|
|
|
|
if type(result) == bytes: |
|
|
|
|
result = result.decode('utf-8') |
|
|
|
|
return result |
|
|
|
|
except Exception as ex: |
|
|
|
|
return str(ex) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def HttpGet2(url, timeout): |
|
|
|
|
import urllib.request |
|
|
|
|
|
|
|
|
|
try: |
|
|
|
|
import ssl |
|
|
|
|
try: |
|
|
|
|
ssl._create_default_https_context = ssl._create_unverified_context |
|
|
|
|
except: |
|
|
|
|
pass |
|
|
|
|
req = urllib.request.urlopen(url, timeout=timeout) |
|
|
|
|
result = req.read().decode('utf-8') |
|
|
|
|
return result |
|
|
|
|
|
|
|
|
|
except Exception as e: |
|
|
|
|
return str(e) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def httpGet(url, timeout=10): |
|
|
|
|
return HttpGet2(url, timeout) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def HttpPost(url, data, timeout=10): |
|
|
|
|
""" |
|
|
|
|
发送POST请求 |
|
|
|
|
@url 被请求的URL地址(必需) |
|
|
|
|
@data POST参数,可以是字符串或字典(必需) |
|
|
|
|
@timeout 超时时间默认60秒 |
|
|
|
|
return string |
|
|
|
|
""" |
|
|
|
|
if sys.version_info[0] == 2: |
|
|
|
|
try: |
|
|
|
|
import urllib |
|
|
|
|
import urllib2 |
|
|
|
|
import ssl |
|
|
|
|
ssl._create_default_https_context = ssl._create_unverified_context |
|
|
|
|
data = urllib.urlencode(data) |
|
|
|
|
req = urllib2.Request(url, data) |
|
|
|
|
response = urllib2.urlopen(req, timeout=timeout) |
|
|
|
|
return response.read() |
|
|
|
|
except Exception as ex: |
|
|
|
|
return str(ex) |
|
|
|
|
else: |
|
|
|
|
try: |
|
|
|
|
import urllib.request |
|
|
|
|
import ssl |
|
|
|
|
try: |
|
|
|
|
ssl._create_default_https_context = ssl._create_unverified_context |
|
|
|
|
except: |
|
|
|
|
pass |
|
|
|
|
data = urllib.parse.urlencode(data).encode('utf-8') |
|
|
|
|
req = urllib.request.Request(url, data) |
|
|
|
|
response = urllib.request.urlopen(req, timeout=timeout) |
|
|
|
|
result = response.read() |
|
|
|
|
if type(result) == bytes: |
|
|
|
|
result = result.decode('utf-8') |
|
|
|
|
return result |
|
|
|
|
except Exception as ex: |
|
|
|
|
return str(ex) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def httpPost(url, data, timeout=10): |
|
|
|
|
return HttpPost(url, data, timeout) |
|
|
|
|
|
|
|
|
|
# ------------------------------ network end ----------------------------- |
|
|
|
|
|
|
|
|
|
# ------------------------------ panel start ----------------------------- |
|
|
|
|
|
|
|
|
|
def isRestart(): |
|
|
|
|