. 1 Import json 2 '' ' . 3 open the page, the page stored directly proxy_list.txt, then treated with a tool file as json! . 4 '' ' . 5 with Open ( " proxy_list.json " , " R & lt " , encoding = " UTF8 " ) AS F: . 6 data_lists = the json.load (F) . 7 . 8 final_data = [] . 9 for data_dict in data_lists: 10 address_sets SET = (data_dict [ " export_address " port = data_dict["port"] 12 type =data_dict["type"] 13 # print(address_sets) 14 for address in address_sets: 15 temp = {type :address + ":" + str(port)} 16 # print(temp) 17 final_data.append(temp) 18 with open("PROXY_LISTS.json","a+",encoding="utf8") as f: 19 json.dump(final_data,f) 20 print(len(final_data))
Import json
'' '
fight to open web pages , directly save the page proxy_list.txt, and then use the tool to its office manager for the json file! '' ' With Open ( "proxy_list.json" , "R & lt" , encoding = "UTF8" ) AS F: . Data_lists JSON = Load (F) final_data = [] for data_dict in data_lists: address_sets = SET (data_dict [ "export_address " ]) # becomes set
去重
port = data_dict["port"]
type =data_dict["type"]
# print(address_sets)
for address in address_sets:
temp = {type :address + ":" + str(port)}
# print(temp)
final_data.append(temp)
with open("PROXY_LISTS.json","a+",encoding="utf8") as f:
json.dump(final_data,f)
print(len(final_data))