modified: amazon/__pycache__/price_match.cpython-39.pyc

modified:   amazon/price_match.py
	modified:   assets/appearance-patent.js
	modified:   assets/delete-brand.js
	modified:   assets/patrol-delete.js
	modified:   assets/price-track.js
	modified:   assets/product-risk.js
	modified:   assets/query-asin.js
	modified:   assets/shop-match.js
	modified:   new_web_source/delete-brand.html
This commit is contained in:
铭坤
2026-04-30 21:57:37 +08:00
parent b315d11c28
commit 668226a99d
2 changed files with 203 additions and 189 deletions

View File

@@ -150,6 +150,17 @@ def calculate_target_price(
# 分支 A第一名是 Amazon US 卖家 (特殊强敌优先) # 分支 A第一名是 Amazon US 卖家 (特殊强敌优先)
price_1 = float(front_end_data.get("top_sellers")[0].get("price")) # 实际第一名价格 price_1 = float(front_end_data.get("top_sellers")[0].get("price")) # 实际第一名价格
if "Amazon" in shop_name_1: if "Amazon" in shop_name_1:
# 增补第6种情况如果是自己购物车 且 第一名是Amazon 且Amazon的价格高于自己的价格 按照这个 :如果低于自己的价格 就跳过,
if is_my_buybox:
if price_1 > my_price:
diff = price_1 - my_price
if diff <= 7 :
return None
else:
return price_1 - 5
else:
return None
else:
return RepricingLogic.situation_4_encounter_amz_us_1st(my_price,price_1) return RepricingLogic.situation_4_encounter_amz_us_1st(my_price,price_1)
# 分支 B不是 Amazon US且目前是自己的购物车 # 分支 B不是 Amazon US且目前是自己的购物车
@@ -360,10 +371,11 @@ class ChromeAmzone:
self.tab.wait.doc_loaded(timeout=5,raise_err=False) self.tab.wait.doc_loaded(timeout=5,raise_err=False)
# 3. 抓取数据 # 3. 抓取数据
print("正在抓取商品数据...") print("===================正在抓取商品数据...====================")
data = self._scrape_data() data = self._scrape_data()
data['timestamp'] = datetime.now().strftime('%Y-%m-%d %H:%M:%S') data['timestamp'] = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
print(f"数据抓取完成: {json.dumps(data)}") print(f"数据抓取完成: {json.dumps(data)}")
print("======================================================")
return data return data
except Exception as e: except Exception as e:
@@ -658,11 +670,11 @@ class AmzonePriceMatch(AmamzonBase):
# for sku_ele in sku_ls[0:2]: # for sku_ele in sku_ls[0:2]:
for sku_ele in sku_ls: for sku_ele in sku_ls:
asin = sku_ele.ele( asin = sku_ele.ele(
'xpath:.//div[contains(@class,"JanusSplitBox-module__container")]//div[contains(@class,"JanusSplitBox-module__panel--") and contains(string(.),"ASIN")]/..//div[last()]', 'xpath:.//div[contains(@class,"JanusSplitBox-module__container")]//div[contains(@class,"JanusSplitBox-module__panel--") and contains(string(.),"ASIN")]/..//div[last()]',
timeout=3).text timeout=3).text
print(f"{self.mark_name}】ASIN {asin} 找到....") print(f"{self.mark_name}】ASIN {asin} 找到....")
try:
# if asin in already_asin: # if asin in already_asin:
# print(f"【{self.mark_name}】{asin} 已经处理过了,跳过") # print(f"【{self.mark_name}】{asin} 已经处理过了,跳过")
# continue # continue
@@ -812,7 +824,9 @@ class AmzonePriceMatch(AmamzonBase):
"priceChangeStatus": "跳过,无需改价", "priceChangeStatus": "跳过,无需改价",
"priceChangePrice": f"{adjust_prices}".replace("None",""), "priceChangePrice": f"{adjust_prices}".replace("None",""),
}) })
except Exception as e:
print(f"{asin},操作出错,{e}")
continue
already_asin.add(asin) already_asin.add(asin)
# 判断是否存在需要翻页的情况 # 判断是否存在需要翻页的情况
@@ -1417,49 +1431,49 @@ class PriceTask:
if __name__ == '__main__': if __name__ == '__main__':
# 使用示例 # 使用示例
# user_info = { user_info = {
# "company": "尾号5578的公司115", "company": "尾号5578的公司115",
# "username": "自动化_Robot", "username": "自动化_Robot",
# "password": "#20zsg25" "password": "#20zsg25"
# } }
# shop_name = "刘建煌" shop_name = "刘建煌"
# country = "法国" country = "法国"
# kill_process('v6') kill_process('v6')
# driver = AmzonePriceMatch(user_info) driver = AmzonePriceMatch(user_info)
# browser = driver.open_shop(shop_name) browser = driver.open_shop(shop_name)
# sw_suc = driver.SwitchingCountries(country) sw_suc = driver.SwitchingCountries(country)
# driver.SwitchPage() driver.SwitchPage()
# risk_listing_filter = "Active" risk_listing_filter = "Active"
# _shopMallName = "Jianhuang 888" _shopMallName = "Jianhuang 888"
# ap_asin ="B0F25Y52PH" ap_asin ="B0F25Y52PH"
# skip_asin = [] skip_asin = []
# for _ in range(3): for _ in range(3):
# try: try:
# sku_ls = driver.search(filter_type=risk_listing_filter) sku_ls = driver.search(filter_type=risk_listing_filter)
# break break
# except Exception as e: except Exception as e:
# print(e) print(e)
# driver.tab.refresh() driver.tab.refresh()
# if len(sku_ls) > 0: if len(sku_ls) > 0:
# print("有数据,开始操作") print("有数据,开始操作")
# for asin, status in driver.run_page_action( for asin, status in driver.run_page_action(
# current_shop_name=_shopMallName, current_shop_name=_shopMallName,
# appoint_asin=ap_asin,skip_asin=skip_asin,mode="asin" appoint_asin=ap_asin,skip_asin=skip_asin,mode="asin"
# ): ):
# print(f"ASIN {asin} 的处理结果: {status}") print(f"ASIN {asin} 的处理结果: {status}")
# print("已完成操作") print("已完成操作")
front_end_data = {'top_sellers': [{'rank': 1, 'price': '52.51', 'stock': '100', 'shop_name': 'Amazon US'}, {'rank': 2, 'price': '62.58', 'stock': '30', 'shop_name': 'Amazon US'}], 'cart_seller': 'Jianhuang 888', 'timestamp': '2026-04-30 09:52:49'} # front_end_data = {'top_sellers': [{'rank': 1, 'price': '52.51', 'stock': '100', 'shop_name': 'Amazon US'}, {'rank': 2, 'price': '62.58', 'stock': '30', 'shop_name': 'Amazon US'}], 'cart_seller': 'Jianhuang 888', 'timestamp': '2026-04-30 09:52:49'}
#
current_Price = 52.51 # current_Price = 52.51
current_shop_name = "Jianhuang 888" # current_shop_name = "Jianhuang 888"
recommended_price = 52.51 # recommended_price = 52.51
recommended_shipping =0.0 # recommended_shipping =0.0
res = calculate_target_price( # res = calculate_target_price(
front_end_data, current_Price, current_shop_name, # front_end_data, current_Price, current_shop_name,
recommended_price, recommended_shipping # recommended_price, recommended_shipping
) # )
print(res) # print(res)
# task_data = {'type': 'price-track-run', 'ts': 1777388166302, 'data': {'task_id': 4892, 'result_id': 6685, 'shop_name': '魏振峰', 'shop_id': '27543917795757', 'platform': '亚马逊', 'company_name': 'rongchuang123', 'shop_mall_name': 'WEIZHENFENG168', 'matched': True, 'match_status': 'MATCHED', 'match_message': None, 'success': False, 'error': None, 'output_filename': None, 'download_url': None, 'task_status': 'RUNNING', 'loop_run_id': 168, 'round_index': 1, 'country_codes': ['DE', 'UK', 'FR', 'IT', 'ES'], 'mode': 'asin', 'skip_asins': {}, 'skip_asins_by_country': {}, 'skip_asin_details_by_country': {}, 'minimum_price_by_country_and_asin': {'DE': {'B0CFY5M3XJ': '38', 'B0DSJGJBWV': '9'}, 'UK': {'B0G2LPSGP5': '30', 'B0G1LY2K8L': '10'}}, 'skip_asin_delete_policy': {'enabled': False, 'mode': 'NONE', 'deleteWhenPriceBelowMinimum': False, 'compareField': 'price', 'thresholdField': 'minimumPrice', 'target': 'skip_asin', 'source': 'frontend-price-track'}, 'delete_skip_asin_when_price_below_minimum': False, 'deleteSkipAsinWhenPriceBelowMinimum': False, 'asin_rows_by_country': {'DE': [{'shopMallName': '', 'asin': 'B0CFY5M3XJ', 'price': '', 'recommendedPrice': '', 'minimumPrice': '38', 'firstPlace': '', 'secondPlace': '', 'cartShopName': '', 'priceChangeStatus': '', 'modifyCount': '', 'status': ''}, {'shopMallName': '', 'asin': 'B0DSJGJBWV', 'price': '', 'recommendedPrice': '', 'minimumPrice': '9', 'firstPlace': '', 'secondPlace': '', 'cartShopName': '', 'priceChangeStatus': '', 'modifyCount': '', 'status': ''}], 'UK': [{'shopMallName': '', 'asin': 'B0G2LPSGP5', 'price': '', 'recommendedPrice': '', 'minimumPrice': '30', 'firstPlace': '', 'secondPlace': '', 'cartShopName': '', 'priceChangeStatus': '', 'modifyCount': '', 'status': ''}, {'shopMallName': '', 'asin': 'B0G1LY2K8L', 'price': '', 'recommendedPrice': '', 'minimumPrice': '10', 'firstPlace': '', 'secondPlace': '', 'cartShopName': '', 'priceChangeStatus': '', 'modifyCount': '', 'status': ''}]}, 'taskId': 4892, 'resultId': 6685, 'shopName': '魏振峰', 'shopId': '27543917795757', 'platformName': '亚马逊', 'companyName': 'rongchuang123', 'shopMallName': 'WEIZHENFENG168', 'matchStatus': 'MATCHED', 'matchMessage': None, 'outputFilename': None, 'downloadUrl': None, 'taskStatus': 'RUNNING', 'loopRunId': 168, 'roundIndex': 1}} # task_data = {'type': 'price-track-run', 'ts': 1777388166302, 'data': {'task_id': 4892, 'result_id': 6685, 'shop_name': '魏振峰', 'shop_id': '27543917795757', 'platform': '亚马逊', 'company_name': 'rongchuang123', 'shop_mall_name': 'WEIZHENFENG168', 'matched': True, 'match_status': 'MATCHED', 'match_message': None, 'success': False, 'error': None, 'output_filename': None, 'download_url': None, 'task_status': 'RUNNING', 'loop_run_id': 168, 'round_index': 1, 'country_codes': ['DE', 'UK', 'FR', 'IT', 'ES'], 'mode': 'asin', 'skip_asins': {}, 'skip_asins_by_country': {}, 'skip_asin_details_by_country': {}, 'minimum_price_by_country_and_asin': {'DE': {'B0CFY5M3XJ': '38', 'B0DSJGJBWV': '9'}, 'UK': {'B0G2LPSGP5': '30', 'B0G1LY2K8L': '10'}}, 'skip_asin_delete_policy': {'enabled': False, 'mode': 'NONE', 'deleteWhenPriceBelowMinimum': False, 'compareField': 'price', 'thresholdField': 'minimumPrice', 'target': 'skip_asin', 'source': 'frontend-price-track'}, 'delete_skip_asin_when_price_below_minimum': False, 'deleteSkipAsinWhenPriceBelowMinimum': False, 'asin_rows_by_country': {'DE': [{'shopMallName': '', 'asin': 'B0CFY5M3XJ', 'price': '', 'recommendedPrice': '', 'minimumPrice': '38', 'firstPlace': '', 'secondPlace': '', 'cartShopName': '', 'priceChangeStatus': '', 'modifyCount': '', 'status': ''}, {'shopMallName': '', 'asin': 'B0DSJGJBWV', 'price': '', 'recommendedPrice': '', 'minimumPrice': '9', 'firstPlace': '', 'secondPlace': '', 'cartShopName': '', 'priceChangeStatus': '', 'modifyCount': '', 'status': ''}], 'UK': [{'shopMallName': '', 'asin': 'B0G2LPSGP5', 'price': '', 'recommendedPrice': '', 'minimumPrice': '30', 'firstPlace': '', 'secondPlace': '', 'cartShopName': '', 'priceChangeStatus': '', 'modifyCount': '', 'status': ''}, {'shopMallName': '', 'asin': 'B0G1LY2K8L', 'price': '', 'recommendedPrice': '', 'minimumPrice': '10', 'firstPlace': '', 'secondPlace': '', 'cartShopName': '', 'priceChangeStatus': '', 'modifyCount': '', 'status': ''}]}, 'taskId': 4892, 'resultId': 6685, 'shopName': '魏振峰', 'shopId': '27543917795757', 'platformName': '亚马逊', 'companyName': 'rongchuang123', 'shopMallName': 'WEIZHENFENG168', 'matchStatus': 'MATCHED', 'matchMessage': None, 'outputFilename': None, 'downloadUrl': None, 'taskStatus': 'RUNNING', 'loopRunId': 168, 'roundIndex': 1}}