Skip to content

Instantly share code, notes, and snippets.

@KensoDev
Created February 19, 2018 14:10
Show Gist options
  • Save KensoDev/32e31d75b572945b21bd8ad1b4885f88 to your computer and use it in GitHub Desktop.
Save KensoDev/32e31d75b572945b21bd8ad1b4885f88 to your computer and use it in GitHub Desktop.
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