You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
963 B
Python

#!/usr/bin/env python3
# panxy, a random proxy connector
from urllib import request, error
import sys
target = "http://theresno.cloud/ip"
prx_api = "http://pubproxy.com/api/proxy?limit=10&http=true&format=txt"
def get_list():
result = request.urlopen(prx_api)
prx_list = result.read().decode()
return prx_list.split('\n')
def test_proxy(prx):
print("Testing proxy " + prx + "... ", end='')
proxy_handler = request.ProxyHandler({'https': 'http://' + prx + '/', 'http': 'http://' + prx + '/' })
opener = request.build_opener(proxy_handler)
try:
result = opener.open(target)
content = result.read().decode()
print('ok.')
except error.HTTPError:
print('fail.')
#except RemoteDisconnected:
# print('fail.')
except error.URLError:
print('down!')
def main():
proxy_list = get_list()
for entry in proxy_list:
test_proxy(entry)
if __name__ == '__main__':
main()