Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2013
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import re,requests,string,random,threading,os,inspect,gc,pdb,urllib2,urllib
  2. def load(filename):
  3.     with open(filename) as f:
  4.         return [line.rstrip() for line in f]
  5. def getpage():
  6.     try:
  7.         curl = urls.pop(0)
  8.         print "working on " +str(curl)
  9.         thepage1 = requests.get(curl).text
  10.         global ctot
  11.         if "Contact Us" in thepage1:
  12.             slist.write("\n" +curl)
  13.             ctot = ctot + 1
  14.     except:
  15.         pass
  16.     finally:
  17.         if len(urls)>0 :
  18.             getpage()      
  19. urls = load('res\urls.txt')
  20. slist = open('res\output.txt', 'a+')
  21. totallinks = len(urls)
  22. global ctot
  23. ctot = 0
  24. tarray=[]
  25. noofthreads = input("Enter the Number of Threads : ")
  26. tout = input("Enter TimeOut Value : ")
  27. if (totallinks<noofthreads) :
  28.     noofthreads = totallinks
  29. if totallinks>0 :
  30.     for xd in range(0,noofthreads):
  31.         t = threading.Thread(target=getpage)
  32.         t.daemon = True
  33.         t.start()
  34.         tarray.append(t)
  35. for t in tarray:
  36.     t.join()
  37. slist.close()
  38. print "Program Completed Its Execution"
  39. raw_input("Press ENTER to Exit the Program")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement