Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2013
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.05 KB | None | 0 0
  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.         thepage1 = requests.get(curl).text
  9.         global ctot
  10.         if "Contact Us" in thepage1:
  11.             slist.write("\n" +curl)
  12.             ctot = ctot + 1
  13.     except:
  14.         pass
  15.     finally:
  16.         if len(urls)>0 :
  17.             getpage()      
  18. urls = load('res\urls.txt')
  19. slist = open('res\output.txt', 'a+')
  20. totallinks = len(urls)
  21. global ctot
  22. ctot = 0
  23. noofthreads = input("Enter the Number of Threads : ")
  24. tout = input("Enter TimeOut Value : ")
  25. if (totallinks<noofthreads) :
  26.     noofthreads = totallinks
  27. if totallinks>0 :
  28.     for xd in range(0,noofthreads):
  29.         t = threading.Thread(target=getpage)
  30.         t.daemon = True
  31.         t.start()
  32.         tarray.append(t)
  33. for t in tarray:
  34.     t.join()
  35. slist.close()
  36. print "Program Completed Its Execution"
  37. raw_input("Press ENTER to Exit the Program")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement