|
| 1 | +# copy list of proxy from html page: http://spys.one/free-proxy-list/UA/ |
| 2 | +# select all lines with proxy using mouse, copy them and paste to file: proxy.txt |
| 3 | +# cat proxy.txt | awk '{ print $2" "$3 }' | awk '{ if($1 ~ /\./ ){print $1" "$2} }' | python3 foxyproxy-generator.py |
| 4 | + |
| 5 | +import json |
| 6 | +import random |
| 7 | +import sys |
| 8 | + |
| 9 | +def get_type(proxy_type:str) -> int: |
| 10 | + prepared_type = proxy_type.upper |
| 11 | + if prepared_type == "HTTP": |
| 12 | + return 1 |
| 13 | + if prepared_type == "HTTPS": |
| 14 | + return 2 |
| 15 | + if prepared_type == "SOCKET5": |
| 16 | + return 3 |
| 17 | + return 1 |
| 18 | + |
| 19 | + |
| 20 | +def get_proxy_description(proxy_address:str, proxy_type:str): |
| 21 | + """ |
| 22 | + proxy address like "91.225.5.43:53495" |
| 23 | + proxy type like: "HTTP", "HTTPS", "SOCKET5" |
| 24 | + """ |
| 25 | + proxy = {} |
| 26 | + proxy["title"] = proxy_address |
| 27 | + proxy["type"] = get_type(proxy_type) # "type": 1, |
| 28 | + proxy_elements = proxy_address.strip().split(":") |
| 29 | + proxy["address"] = proxy_elements[0] |
| 30 | + proxy["port"] = proxy_elements[1] |
| 31 | + proxy["active"] = True |
| 32 | + color_red = str(hex(random.randint(0, 255)))[2:] |
| 33 | + color_green = str(hex(random.randint(0, 255)))[2:] |
| 34 | + color_blue = str(hex(random.randint(0, 255)))[2:] |
| 35 | + proxy["color"] = "#" + color_red + color_green + color_blue |
| 36 | + proxy["id"] = "17tj6e157" + str(random.randint(1000000000, 9999999999)) |
| 37 | + return proxy |
| 38 | + |
| 39 | + |
| 40 | +if __name__=="__main__": |
| 41 | + """ input lines like |
| 42 | + 195.74.72.129:49383 HTTPS |
| 43 | + 91.225.5.43:53495 HTTP |
| 44 | + 109.200.132.147:8888 SOCKS5 |
| 45 | + """ |
| 46 | + input_lines = list() |
| 47 | + for each_input in sys.stdin: |
| 48 | + input_lines.append(each_input.strip().split(" ")) |
| 49 | + |
| 50 | + document = {} |
| 51 | + document["mode"] = "disabled" |
| 52 | + document["logging"] = {} |
| 53 | + document["logging"]["active"] = True |
| 54 | + document["logging"]["maxSize"] = 500 |
| 55 | + document["proxySettings"] = list(map(lambda x:get_proxy_description(x[0], x[1]), input_lines)) |
| 56 | + |
| 57 | + print(json.dumps(document, indent=2)) |
0 commit comments