import sys import thread import pycurl import StringIO import re impor

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import sys
import thread
import pycurl
import StringIO
import re
import md5
import string
import random
random.seed(14)
fi = open('input.txt','r')
list = fi.readlines()
def some_function():
global list, fo, count_thread
while(len(list)>0):
urlz = list.pop()
data = StringIO.StringIO()
curl = pycurl.Curl()
curl.setopt(pycurl.FOLLOWLOCATION, 0)
curl.setopt(pycurl.CONNECTTIMEOUT, 20)
curl.setopt(pycurl.URL, urlz)
curl.setopt(pycurl.WRITEFUNCTION, data.write)
try:
curl.perform()
except:
pass
curl.close()
rez = data.getvalue()
#d = [random.choice(string.letters) for x in xrange(10)]
#s = "".join(d)
hash = md5.new(urlz).hexdigest()
fo = open('./bufdir/' + hash + '.txt','w')
#print rez
fo.write(str(urlz) + '\n' + rez)
fo.close()
count_thread -= 1
count_thread = 0
for i in xrange(0,30):
count_thread += 1
thread.start_new_thread(some_function,())
while(count_thread>0):
pass
fi.close()