more error handling, emojis
This commit is contained in:
parent
005a3d77dc
commit
9dc3ffe064
16
panxy.py
16
panxy.py
@ -2,6 +2,7 @@
|
|||||||
# panxy, a random proxy connector
|
# panxy, a random proxy connector
|
||||||
|
|
||||||
from urllib import request, error
|
from urllib import request, error
|
||||||
|
import socket
|
||||||
import sys
|
import sys
|
||||||
target = "http://theresno.cloud/ip"
|
target = "http://theresno.cloud/ip"
|
||||||
prx_api = "http://pubproxy.com/api/proxy?limit=10&http=true&format=txt"
|
prx_api = "http://pubproxy.com/api/proxy?limit=10&http=true&format=txt"
|
||||||
@ -19,18 +20,25 @@ def test_proxy(prx):
|
|||||||
proxy_handler = request.ProxyHandler({'https': 'http://' + prx + '/', 'http': 'http://' + prx + '/' })
|
proxy_handler = request.ProxyHandler({'https': 'http://' + prx + '/', 'http': 'http://' + prx + '/' })
|
||||||
opener = request.build_opener(proxy_handler)
|
opener = request.build_opener(proxy_handler)
|
||||||
try:
|
try:
|
||||||
result = opener.open(target)
|
result = opener.open(target, timeout=5)
|
||||||
content = result.read().decode()
|
content = result.read().decode()
|
||||||
print(srv_string + 'ok.')
|
print(srv_string + 'ok. \u2705')
|
||||||
return True
|
return True
|
||||||
except error.HTTPError:
|
except error.HTTPError:
|
||||||
print(srv_string + 'fail.')
|
print(srv_string + 'fail. \u274c')
|
||||||
return False
|
return False
|
||||||
#except RemoteDisconnected:
|
#except RemoteDisconnected:
|
||||||
# print('fail.')
|
# print('fail.')
|
||||||
except error.URLError:
|
except error.URLError:
|
||||||
print(srv_string + 'down!')
|
print(srv_string + 'down! \u2935')
|
||||||
return False
|
return False
|
||||||
|
#except error.RemoteDisconnected:
|
||||||
|
# print(srv_string + 'connection fail!')
|
||||||
|
# return False
|
||||||
|
except socket.timeout:
|
||||||
|
print(srv_string + 'timeout! \u23f3')
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user