ProxyValidSchedule.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. # -*- coding: utf-8 -*-
  2. """
  3. -------------------------------------------------
  4. File Name: ProxyValidSchedule.py
  5. Description : 验证useful_proxy_queue中的代理,将不可用的移出
  6. Author : JHao
  7. date: 2017/3/31
  8. -------------------------------------------------
  9. Change Activity:
  10. 2017/3/31: 验证useful_proxy_queue中的代理
  11. -------------------------------------------------
  12. """
  13. __author__ = 'JHao'
  14. import sys
  15. sys.path.append('../')
  16. from Schedule.ProxyCheck import ProxyCheck
  17. class ProxyValidSchedule(object):
  18. def __init__(self):
  19. pass
  20. def __validProxy(self, threads=5):
  21. """
  22. 验证useful_proxy代理
  23. :param threads: 线程数
  24. :return:
  25. """
  26. thread_list = list()
  27. for index in range(threads):
  28. thread_list.append(ProxyCheck())
  29. for thread in thread_list:
  30. thread.daemon = True
  31. thread.start()
  32. for thread in thread_list:
  33. thread.join()
  34. def main(self):
  35. self.__validProxy()
  36. def run():
  37. p = ProxyValidSchedule()
  38. p.main()
  39. if __name__ == '__main__':
  40. p = ProxyValidSchedule()
  41. p.main()