同步 Gitee 应用代码更新
This commit is contained in:
@@ -11,7 +11,7 @@ from amazon.tool import show_notification,get_shop_info,remove_special_character
|
||||
from config import runing_task, runing_shop,DELETE_BRAND_API_BASE
|
||||
|
||||
class RepricingLogic:
|
||||
|
||||
|
||||
@staticmethod
|
||||
def situation_1_general_decrease(my_price, rank1_price, is_first_time=False):
|
||||
"""
|
||||
@@ -460,6 +460,8 @@ class AmzonePriceMatch(AmamzonBase):
|
||||
super().__init__(user_info,socket_port)
|
||||
self.already_asin = set()
|
||||
|
||||
|
||||
|
||||
def reset_already_asin(self):
|
||||
self.already_asin = set()
|
||||
self.log("already_asin 已重置")
|
||||
@@ -513,14 +515,15 @@ class AmzonePriceMatch(AmamzonBase):
|
||||
self.log("开始执行...")
|
||||
num = 0
|
||||
retry_num = 0
|
||||
already_asin = set()
|
||||
get_page_faild = 0
|
||||
already_asin = self.already_asin
|
||||
#获取当前国家
|
||||
current_country_ele = self.tab.ele('xpath://div[@class="dropdown-account-switcher-header-label"]/span[last()]',
|
||||
timeout=20)
|
||||
current_country = current_country_ele.text.strip()
|
||||
max_retry_num = 5
|
||||
while retry_num < max_retry_num: # 最多重试3次
|
||||
total_page = 0
|
||||
current_page = 0
|
||||
while retry_num < max_retry_num:
|
||||
try:
|
||||
if appoint_asin is not None:
|
||||
self.log(f"指定asin操作,{appoint_asin}")
|
||||
@@ -536,6 +539,7 @@ class AmzonePriceMatch(AmamzonBase):
|
||||
page_pamel = self.tab.eles('xpath://kat-pagination', timeout=5)
|
||||
if len(page_pamel) > 0:
|
||||
current_page = page_pamel[0].sr('xpath:.//ul[@class="pages"]//li[@aria-current="true"]').text
|
||||
current_page = int(current_page.strip())
|
||||
#测试=====
|
||||
# if int(current_page) > 1:
|
||||
# break
|
||||
@@ -546,17 +550,12 @@ class AmzonePriceMatch(AmamzonBase):
|
||||
total_page = page_pamel[0].sr.eles(
|
||||
'xpath:.//ul[@class="pages"]//span[@class="page__inner"][last()]')
|
||||
if len(total_page) > 0:
|
||||
total_page = total_page[-1].text
|
||||
else:
|
||||
total_page = 0
|
||||
total_page = int(total_page[-1].text.strip())
|
||||
|
||||
self.log(f"【{self.mark_name}】当前页码: {current_page} / 总页数: {total_page}")
|
||||
get_page_faild = 0
|
||||
except Exception as e:
|
||||
self.log(f"获取页码失败,{e}")
|
||||
get_page_faild += 1
|
||||
if get_page_faild > 2:
|
||||
show_notification(f"【{self.mark_name}】获取页码失败超3次停止任务!")
|
||||
break
|
||||
|
||||
|
||||
# 保存当前URL,用于失败重试时访问
|
||||
try:
|
||||
@@ -767,6 +766,12 @@ class AmzonePriceMatch(AmamzonBase):
|
||||
retry_num += 1
|
||||
self.tab.refresh()
|
||||
self.tab.wait.doc_loaded(raise_err=False, timeout=120)
|
||||
#检查页数是否相等,不相等则继续
|
||||
self.log(f"开始检查页数,当前页数 {current_page} / {total_page}")
|
||||
if total_page != 0 and current_page!= 0 and current_page < total_page:
|
||||
self.log(f"检查到页数还未完成,重启浏览器继续")
|
||||
raise RuntimeError(f"与页面的连接已断开,检查到页数还未完成,重启浏览器继续")
|
||||
|
||||
|
||||
class PriceTask(TaskBase):
|
||||
task_name = "跟价-TASK"
|
||||
@@ -922,6 +927,7 @@ class PriceTask(TaskBase):
|
||||
miniprice_info = minimum_price_by_country_and_asin.get(country_code,{})
|
||||
|
||||
current_url = None
|
||||
max_retries = 200
|
||||
for _ in range(max_retries):
|
||||
try:
|
||||
self.process_country(driver, country_code, task_id, shop_name, risk_listing_filter,
|
||||
|
||||
Reference in New Issue
Block a user