IPProxy.py 764 B

12345678910111213141516171819202122232425262728
  1. # coding:utf-8
  2. from multiprocessing import Value, Queue, Process
  3. from api.apiServer import start_api_server
  4. from db.DataStore import store_data
  5. from validator.Validator import validator, getMyIP
  6. from spider.ProxyCrawl import startProxyCrawl
  7. from config import TASK_QUEUE_SIZE
  8. if __name__ == "__main__":
  9. myip = getMyIP()
  10. DB_PROXY_NUM = Value('i', 0)
  11. q1 = Queue(maxsize=TASK_QUEUE_SIZE)
  12. q2 = Queue()
  13. p0 = Process(target=start_api_server)
  14. p1 = Process(target=startProxyCrawl, args=(q1, DB_PROXY_NUM,myip))
  15. p2 = Process(target=validator, args=(q1, q2, myip))
  16. p3 = Process(target=store_data, args=(q2, DB_PROXY_NUM))
  17. p0.start()
  18. p1.start()
  19. p2.start()
  20. p3.start()
  21. p0.join()
  22. p1.join()
  23. p2.join()
  24. p3.join()