-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
43 lines (39 loc) · 1.29 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import socket
import urllib.request
import json
host = ""
port = 25565
server = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
server.bind((host,port,))
server.listen(1)
def findbestproxy(ssl,proxytype,timeout):
if ssl == 1:
ssl = "yes"
else:
ssl = "no"
link = 'https://api.proxyscrape.com?request=displayproxies&proxytype='+proxytype+'&timeout='+timeout+'&format=json&anonymity=elite&ssl='+ssl+''
response = urllib.request.urlopen(link)
output = response.read().decode()
output_2 = output.replace("\r","")
dictionary = json.loads(output_2)
bestproxy = 0
bestspeed = dictionary[0]['timeout']
for i in range(len(dictionary)):
dictionary[i]['timeout']
if dictionary[i]['timeout'] < bestspeed:
bestspeed = dictionary[i]['timeout']
bestproxy = i
aspects = []
for i in dictionary[bestproxy]:
aspects.append(i)
proxy_info = []
for i in aspects:
proxy_info.append(i+": "+str(dictionary[bestproxy][i]))
proxy_info_string = "\n".join(proxy_info)
return proxy_info_string
while True:
con,addr = server.accept()
variables = con.recv(4096).decode()
variables = variables.split("\n")
con.send(findbestproxy(int(variables[0]),variables[1],variables[2]).encode())
con.close()