|
@@ -25,66 +25,6 @@ class TaobaoMain:
|
|
|
self.cumulative_stored = 0
|
|
self.cumulative_stored = 0
|
|
|
self.cumulative_skipped = 0
|
|
self.cumulative_skipped = 0
|
|
|
|
|
|
|
|
- def get_status(self, status):
|
|
|
|
|
- if status not in (2, 3, 4):
|
|
|
|
|
- logger.warning(f"未知状态值: {status}, 跳过状态上报")
|
|
|
|
|
- return
|
|
|
|
|
- if status == 2:
|
|
|
|
|
- parmas = {
|
|
|
|
|
- "collect_task_allocate_id": self.task_id, "status": status, "finish_status": 0,
|
|
|
|
|
- "start_time": int(time.time())
|
|
|
|
|
- }
|
|
|
|
|
- if status == 3:
|
|
|
|
|
- parmas = {
|
|
|
|
|
- "collect_task_allocate_id": self.task_id, "status": status, "finish_status": 1,
|
|
|
|
|
- "real_count": self.crawl_count, "end_time": int(time.time()),
|
|
|
|
|
- }
|
|
|
|
|
- if status == 4:
|
|
|
|
|
- parmas = {
|
|
|
|
|
- "collect_task_allocate_id": self.task_id, "status": status, "finish_status": 0,
|
|
|
|
|
- "end_time": int(time.time())}
|
|
|
|
|
- # url = "http://scheduletest.dfwy.tech/api/collect_equipment_execute/result_report"
|
|
|
|
|
- url = "http://scheduleapi.findit.ltd/api/collect_equipment_execute/result_report"
|
|
|
|
|
-
|
|
|
|
|
- try:
|
|
|
|
|
- res = requests.get(url, params=parmas, timeout=20)
|
|
|
|
|
- res.raise_for_status()
|
|
|
|
|
- logger.info("状态上报: %s", res.text[:500])
|
|
|
|
|
- except Exception as e:
|
|
|
|
|
- logger.warning(f"状态上报失败: {e}")
|
|
|
|
|
-
|
|
|
|
|
- def heartbeat_task(self):
|
|
|
|
|
- url = "https://scheduleapi.findit.ltd/api/collect_equipment_execute/heartbeat"
|
|
|
|
|
- params = {
|
|
|
|
|
- "collect_task_allocate_id": self.task_id,
|
|
|
|
|
- }
|
|
|
|
|
- try:
|
|
|
|
|
- res = requests.get(url, params=params, timeout=20)
|
|
|
|
|
- logger.info("心跳任务上报成功")
|
|
|
|
|
- except Exception as e:
|
|
|
|
|
- logger.info(f"心跳任务上报失败{str(e)}")
|
|
|
|
|
-
|
|
|
|
|
- def get_task(self):
|
|
|
|
|
- """获取当前设备绑定的淘宝待执行任务(快照版)。"""
|
|
|
|
|
- sql = """
|
|
|
|
|
- SELECT t.*
|
|
|
|
|
- FROM `retrieve_collect_task_allocate` t
|
|
|
|
|
- INNER JOIN `retrieve_collect_equipment_account` a
|
|
|
|
|
- ON t.`collect_equipment_account_id` = a.`id`
|
|
|
|
|
- WHERE a.`device_id` = %s
|
|
|
|
|
- AND t.`platform` = 1
|
|
|
|
|
- AND t.`status` = 1
|
|
|
|
|
- AND t.`snapshot_collect_status` = 0
|
|
|
|
|
- LIMIT 1
|
|
|
|
|
- """
|
|
|
|
|
- task_list = self.db_online.select_data(sql, (TB_DEVICE_ID,))
|
|
|
|
|
-
|
|
|
|
|
- if not task_list:
|
|
|
|
|
- return {}
|
|
|
|
|
-
|
|
|
|
|
- task_dict = task_list[0]
|
|
|
|
|
- self.task_id = task_dict["id"]
|
|
|
|
|
- return task_dict
|
|
|
|
|
|
|
|
|
|
def run(self):
|
|
def run(self):
|
|
|
|
|
|