3
0

start_run_yaoyigou.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. print(self.task_dict)
  25. if not self.task_dict:
  26. logger.info(f"{PLATFORM_NAME}暂无任务")
  27. time.sleep(35)
  28. continue
  29. crawl_count, is_success = Yaoyigou(self.task_dict,spider_schedule).run()
  30. spider_schedule.stop()
  31. else:
  32. spider_schedule.start()
  33. print('休息')
  34. time.sleep(35)
  35. time.sleep(30)
  36. if __name__ == "__main__":
  37. import random
  38. import time
  39. YYG().run()