strategy.py 594 B

1234567891011121314151617181920212223242526272829303132
  1. from abc import ABC, abstractmethod
  2. # 策略
  3. class Strategy(ABC):
  4. @abstractmethod
  5. def crawl(self):
  6. pass
  7. # TODO 不同平台 不同策略
  8. class XiaoniangaoHomePageStrategy(Strategy):
  9. def crawl(self):
  10. # 具体逻辑
  11. print("XiaoniangaoHomePageStrategy")
  12. return
  13. class XiguaHomePageStrategy(Strategy):
  14. def crawl(self):
  15. # 具体逻辑
  16. print("XiguaHomePageStrategy")
  17. return
  18. class ShipinhaoHomePageStrategy(Strategy):
  19. def crawl(self):
  20. # 具体逻辑
  21. print("ShipinhaoHomePageStrategy")
  22. return