run.py 771 B

123456789101112131415161718192021222324252627
  1. import logging
  2. import sys
  3. from crawler import config
  4. from crawler.context import Context
  5. from crawler.strategy import XiaoniangaoHomePageStrategy
  6. class Main:
  7. @staticmethod
  8. def main(argv):
  9. # Platform Strategy Env
  10. print("start run crawler...")
  11. print("Platform = " + argv[0])
  12. print("Strategy = " + argv[1])
  13. print("Env = " + argv[2])
  14. print("Platform = " + config.PLATFORM['xiaoniangao'])
  15. print("Strategy = " + config.STRATEGY['home_page'])
  16. print("Env = " + config.ENV['test'])
  17. # TODO 根据参数判断 具体的策略
  18. strategy = XiaoniangaoHomePageStrategy()
  19. context = Context(strategy)
  20. context.strategy.crawl()
  21. if __name__ == '__main__':
  22. Main.main(sys.argv)