You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
605 B
22 lines
605 B
6 years ago
|
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
|