3
0

start_run_yaoyigou.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. from spiders.yaoyigou.yaoyigou_crawl import Yaoyigou
  2. from commons.collect_schedule_runner import run_scheduled_loop
  3. from commons.scheduler import CrawlerScheduler
  4. from commons.Logger import logger
  5. import time
  6. PLATFORM_NAME = "药易购"
  7. PLATFORM_ID = 8
  8. class YYG():
  9. def __init__(self):
  10. # self.db_online = MySQLPool39()
  11. self.crawl_count = ""
  12. self.task_id = ""
  13. self.task_dict=''
  14. def run(self):
  15. spider_schedule = CrawlerScheduler(1,PLATFORM_ID)
  16. spider_schedule.start()
  17. time.sleep(3)
  18. while 1 :
  19. print(f'not spider_schedule.end:{not spider_schedule.end}')
  20. if(not spider_schedule.end):
  21. print('进入工作')
  22. self.task_dict = spider_schedule.get_task()
  23. #self.task_dict = {'id': 149, 'company_id': 0, 'product_name': '藿香正气合剂', 'product_specs': '', 'product_brand': '999', 'product_keyword': '', 'current_page': 0, 'start_offset': 0}
  24. self.task_dict = {'id': 149, 'company_id': 0, 'product_name': '感冒灵', 'product_specs': '', 'product_brand': '999', 'product_keyword': '', 'current_page': 0, 'start_offset': 0}
  25. print(self.task_dict)
  26. if not self.task_dict:
  27. logger.info(f"{PLATFORM_NAME}暂无任务")
  28. time.sleep(35)
  29. continue
  30. crawl_count, is_success = Yaoyigou(self.task_dict,spider_schedule).run()
  31. spider_schedule.stop()
  32. else:
  33. spider_schedule.start()
  34. print('休息')
  35. time.sleep(35)
  36. time.sleep(30)
  37. if __name__ == "__main__":
  38. import random
  39. import time
  40. YYG().run()