proxy_list for match in reProxy finditer data ip match group port int

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
proxy_list = []
for match in reProxy.finditer(data):
ip = match.group(1)
port = int(match.group(2))
ip_parts = [int(x) for x in ip.split('.')]
if ( ip_parts[0] == 10 or
(ip_parts[0] == 192 and ip_parts[1] == 168) or
(ip_parts[0] == 172 and 16 <= ip_parts[1] <= 31) or
(ip == '127.0.0.1') or
(255 in ip_parts)):
break
proxy = '%s:%s' % (ip,port)
proxy_list.append(proxy)
return proxy_list