Commit b8a2e595 authored by 邱阿朋's avatar 邱阿朋

fix(vc): 优化销售数据导出功能

- 添加异常处理,解决元素未找到时的刷新重试问题
- 优化等待和刷新逻辑,提高导出成功率- 引入 ElementNotFoundError 异常类,用于捕获元素未找到的异常
parent db70747a
# coding: utf-8 # coding: utf-8
import pandas as pd import pandas as pd
from DrissionPage.errors import ElementNotFoundError
from app.vc import rabbit from app.vc import rabbit
from app.helper import domain, file from app.helper import domain, file
...@@ -42,8 +43,10 @@ class ProductSales(AutoInterface): ...@@ -42,8 +43,10 @@ class ProductSales(AutoInterface):
self.page.ele("#raw_xlsx_btn").click() self.page.ele("#raw_xlsx_btn").click()
self.logger.debug("点击导出等待下载任务提交...") self.logger.debug("点击导出等待下载任务提交...")
self.page.wait(3)
while True: while True:
try:
self.page.wait(3)
self.page.ele("#downloadManager").click() self.page.ele("#downloadManager").click()
self.logger.debug("等待数据加载...") self.logger.debug("等待数据加载...")
self.page.wait(5) self.page.wait(5)
...@@ -59,8 +62,11 @@ class ProductSales(AutoInterface): ...@@ -59,8 +62,11 @@ class ProductSales(AutoInterface):
# 点击下载链接 # 点击下载链接
link.click.to_download(rename=self.result_file_name) link.click.to_download(rename=self.result_file_name)
self.logger.debug("等待下载...") self.logger.debug("等待下载...")
file.wait_for_downloads(self.result_file_name,3600) file.wait_for_downloads(self.result_file_name, 3600)
break break
except ElementNotFoundError:
self.page.refresh()
continue
def push_data_queue(self): def push_data_queue(self):
rabbit.connection() rabbit.connection()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment