Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3
- import requests
- from base64 import b64decode
- import os
- def get_csv():
- #download and save the csv file
- print("[INFO] Fetching csv file...")
- tmp = requests.get("http://www.vpngate.net/api/iphone/")
- csv = open("vpngate.proixes.csv", "w")
- csv.write(tmp.text)
- csv.close()
- try:
- open("vpngate.proixes.csv", "r")
- print("[INFO] vpngate.proxies.csv exists. Using that.\n Delete to fetch new version.")
- except FileNotFoundError:
- get_csv()
- print("[INFO] Sorting by something...")
- csv = open("vpngate.proixes.csv", "r").read().split("\n")[1:-2]
- legend = [i.lower() for i in csv.pop(0)[1:].split(",")]
- #dict from csv. Fields in legend
- csv_dict = [dict(zip(legend, csv[i].split(","))) for i in range(1,len(csv))]
- dict_sorted = sorted(csv_dict, key=lambda d: d['score'])
- #sort by score, speed, hostname, whatever rly.
- print("[INFO] Writing files")
- os.mkdir("opvpn files")
- os.chdir("opvpn files")
- for i, li in enumerate(dict_sorted):
- name = f"{i}-{li['countryshort']}_{li['hostname']}_{li['ip']}.ovpn"
- file = open(name, "w")
- file.write(b64decode(li['openvpn_configdata_base64']).decode("utf-8"))
- file.close()
- print("done")
Add Comment
Please, Sign In to add comment