Khalsa Labs

Auto Website Visitor Script in Python

Generate or Increase traffic by auto website visitor script in python, Here is a small script for visit websites automatically using random proxies and random user-agents. This python script is doing cool stuff by choosing random websites pages to visit with different browsers and users Identities at same time.

Its just for a testing purpose , may be its never illegal…

code:

 

##--- 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()

 

NOTE: you have to make three text files in the same directory where the script is saved,for save website lists, proxy lists, user-agent string lists(browsers lists).

the sample is included here , autovisiter

 

The following two tabs change content below.
Python Developer and DIY lover.

want to comment ??

Your email address will not be published. Required fields are marked *



  • Archit says:

    and what after this?

  • khalsalabs says:

    just run the code in python2.7 and you got what you find ….

  • bTw says:

    thanks for script,..
    i have try, but i get replay msg
    37 total connections, success = 32 failed= 5
    Can you explain to me what happened?

    • khalsalabs says:

      Welcome bTW, Gud u make progress and have 32 proxied connections to your URL, it means you got 32 visits from different addresses to your Website/Blog or any URL you Provided..

  • shaant00 says:

    not working

  • undzie says:

    thats great script!! but can you add some referral for that? so we can give some fake referral…

  • above2all says:

    I think u need to update the codes for new pyton version. It is not working brother. lots of error.

  • greart codes…thanx for that

  • vijay says:

    but not showing in google analytic page view