from threading import Thread from random import random from urllib2 im

 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
from threading import Thread
from random import random
from urllib2 import Request,urlopen
class WCrowder:
def __init__(self,url,p_list,user_agent='WCrowder/0.1'):
self.url=url
self.p_list=p_list
self.user_agent=user_agent
def crow(self,proxy):
p_addr,p_port=proxy
rnd=random()
req=Request(self.url)
req.add_header('User-agent','%s %s' %(self.user_agent,rnd))
req.add_header('Host',rnd)
req.set_proxy('%s:%s' %proxy,'http')
try:
urlopen(req)
except:
return False
return True
def start(self,round_trip=False):
while True:
for proxy in self.p_list:
Thread(target=self.crow,args=(proxy,)).run()
if not round_trip:
break