testProxyFetcher.py 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. # -*- coding: utf-8 -*-
  2. """
  3. -------------------------------------------------
  4. File Name: testProxyFetcher
  5. Description :
  6. Author : JHao
  7. date: 2020/6/23
  8. -------------------------------------------------
  9. Change Activity:
  10. 2020/6/23:
  11. -------------------------------------------------
  12. """
  13. __author__ = 'JHao'
  14. from fetcher.proxyFetcher import ProxyFetcher
  15. from handler.configHandler import ConfigHandler
  16. def testProxyFetcher():
  17. conf = ConfigHandler()
  18. proxy_getter_functions = conf.fetchers
  19. proxy_counter = {_: 0 for _ in proxy_getter_functions}
  20. for proxyGetter in proxy_getter_functions:
  21. for proxy in getattr(ProxyFetcher, proxyGetter.strip())():
  22. if proxy:
  23. print('{func}: fetch proxy {proxy}'.format(func=proxyGetter, proxy=proxy))
  24. proxy_counter[proxyGetter] = proxy_counter.get(proxyGetter) + 1
  25. for key, value in proxy_counter.items():
  26. print(key, value)
  27. if __name__ == '__main__':
  28. testProxyFetcher()