From a63bdb315218b7d99eb6ae78488857bf5bcc20da Mon Sep 17 00:00:00 2001 From: BlucyBlue Date: Sun, 20 Jan 2019 18:59:33 +0100 Subject: [PATCH] Created new file 'load_proxies.py' to store functions for reading proxies from files, and checking proxy anonimity. Created the function 'load_proxies_from_csv' which reads proxies from a .csv file to a list of named tuples. --- load_proxies.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 load_proxies.py diff --git a/load_proxies.py b/load_proxies.py new file mode 100644 index 00000000..bfad7a83 --- /dev/null +++ b/load_proxies.py @@ -0,0 +1,22 @@ +import csv +import requests +import time +from collections import namedtuple + +""" +A function which loads proxies from a .csv file, to a list. + +Inputs: path to .csv file which contains proxies, described by fields: 'ip', 'port', 'protocol'. + +Outputs: list containing proxies stored in named tuples. +""" + + +def load_proxies_from_csv(path_to_list): + Proxy = namedtuple('Proxy', ['ip', 'port', 'protocol']) + + with open(path_to_list, 'r') as csv_file: + csv_reader = csv.DictReader(csv_file) + proxies = [Proxy(line['ip'],line['port'],line['protocol']) for line in csv_reader] + + return proxies \ No newline at end of file