import urllib import threading from Queue import Queue def checkit lin

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import urllib
import threading
from Queue import Queue
def checkit():
line = q.get()
print 'checking %s' % line
x = urllib.urlopen("http://www.{0}".format(line)).getcode()
print str(x)
q.task_done()
q = Queue()
f = open("urls.txt", "r")
try:
for line in f:
q.put(line)
finally:
f.close()
for x in xrange(q.qsize()):
t = threading.Thread(target=checkit)
t.start()
q.join()