forked from seeditsolution/pythonprogram
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Auto Website Visitor
62 lines (54 loc) · 1.47 KB
/
Auto Website Visitor
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
51
52
53
54
55
56
57
58
59
60
61
62
##--- Auto Website Visitor by khalsalabs ---- ####
import urllib2
import random
import threading
import sys
import time
class Connect:
req = urllib2.Request('http://your-website-name.com')
con_sucess, con_failed, con_total=0,0,0
url_total, proxy_total= 0,0
url_list =[]
proxy_list= []
agent_list =[]
def __init__(self):
pF = open('proxy.txt','r')
pR = pF.read()
self.proxy_list = pR.split('n')
uF = open('url.txt','r')
uR = uF.read()
self.url_list = uR.split('n')
aF = open('agent.txt','r')
aR = aF.read()
self.agent_list = aR.split('n')
def prep_con(self):
rURL = random.randint(0,(len(self.url_list))-1)
self.req = urllib2.Request(self.url_list[rURL])
rAGENT = random.randint(0,(len(self.agent_list))-1)
self.req.add_header('User-agent',self.agent_list[rAGENT])
def make_con(self):
count, time_stamp =0,0
for proxy in self.proxy_list:
self.req.set_proxy(proxy,'http')
if count%4==0:
if self.con_total < 2*count:
time_stamp = 6
else:
time_stamp = 3
threading.Thread(target=self.visitURL).start()
time.sleep(time_stamp)
count += 1
def visit(self):
try:
f = urllib2.urlopen(self.req)
self.con_sucess += 1
except:
self.con_failed += 1
self.con_total += 1
print self.con_total,"total connections, success = ",self.con_sucess," failed= ",self.con_failed
def visitURL(self):
self.prep_con()
self.visit()
if __name__ == "__main__":
cnct = Connect()
cnct.make_con()