Skip to content

Commit

Permalink
Created new file 'load_proxies.py' to store functions for reading pro…
Browse files Browse the repository at this point in the history
…xies 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.
  • Loading branch information
BlucyBlue authored and TheYahya committed Jan 29, 2019
1 parent 263b8b3 commit a63bdb3
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions load_proxies.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit a63bdb3

Please sign in to comment.