Created
February 19, 2018 14:10
-
-
Save KensoDev/32e31d75b572945b21bd8ad1b4885f88 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import urllib2 | |
import sys | |
import multiprocessing | |
with open("users.csv", 'r') as csvfile: | |
rows = [row for row in csv.reader(csvfile)] | |
csvfile.close() | |
def check(row): | |
url = row[2] | |
try: | |
connection = urllib2.urlopen(url) | |
code = connection.getcode() | |
connection = urllib2.urlopen(url) | |
code = connection.getcode() | |
connection.close() | |
except urllib2.HTTPError, e: | |
code = e.getcode() | |
row.append(code) | |
print(row) | |
sys.stdout.flush() | |
jobs = [] | |
for row in rows: | |
p = multiprocessing.Process(target=check, args=(row,)) | |
jobs.append(p) | |
p.start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment