start_run_yaofangwang.py 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. from spiders.yaofangwang.yaofangwang_crawl import YaofangwangCrawl
  2. from commons.collect_schedule_runner import run_scheduled_loop
  3. from commons.scheduler import CrawlerScheduler
  4. from commons.Logger import logger
  5. PLATFORM_NAME = "药房网"
  6. PLATFORM_ID = 11
  7. class YFW():
  8. def __init__(self):
  9. # self.db_online = MySQLPool39()
  10. self.crawl_count = ""
  11. self.task_id = ""
  12. self.task_dict=''
  13. def run(self):
  14. spider_schedule = CrawlerScheduler(1,11)
  15. spider_schedule.start()
  16. time.sleep(3)
  17. while 1 :
  18. print(f'not spider_schedule.end:{not spider_schedule.end}')
  19. if(not spider_schedule.end):
  20. print('进入工作')
  21. self.task_dict = spider_schedule.get_task()
  22. #self.task_dict = {'id': 149, 'company_id': 0, 'product_name': '藿香正气合剂', 'product_specs': '', 'product_brand': '999', 'product_keyword': '', 'current_page': 0, 'start_offset': 0}
  23. print(self.task_dict)
  24. if not self.task_dict:
  25. logger.info(f"{PLATFORM_NAME}暂无任务")
  26. time.sleep(35)
  27. continue
  28. crawl_count, is_success = YaofangwangCrawl(self.task_dict,spider_schedule).run()
  29. spider_schedule.stop()
  30. else:
  31. spider_schedule.start()
  32. print('休息')
  33. time.sleep(35)
  34. time.sleep(30)
  35. TASK_LIST = [
  36. {"brand": "天和", "product": "骨通贴膏", "spec": ""},
  37. {"brand": "天和", "product": "追风膏", "spec": ""},
  38. {"brand": "天和", "product": "麝香壮骨膏", "spec": ""},
  39. {"brand": "达因", "product": "维生素D滴剂", "spec": ""},
  40. {"brand": "999", "product": "益血生胶囊", "spec": ""},
  41. {"brand": "999", "product": "尪痹胶囊", "spec": ""},
  42. {"brand": "999", "product": "气滞胃痛颗粒", "spec": ""},
  43. {"brand": "好娃娃", "product": "小儿氨酚烷胺颗粒", "spec": ""},
  44. {"brand": "澳诺", "product": "澳诺葡萄糖酸钙锌口服溶液", "spec": ""},
  45. {"brand": "易善复", "product": "多烯磷脂酰胆碱胶囊", "spec": ""},
  46. {"brand": "达因", "product": "伊可新维生素AD滴剂", "spec": ""},
  47. {"brand": "999", "product": "消痔软膏", "spec": ""},
  48. ]
  49. if __name__ == "__main__":
  50. import random
  51. import time
  52. YFW().run()
  53. #
  54. # run_scheduled_loop(PLATFORM_NAME, PLATFORM_ID, YaofangwangCrawl)