From 668226a99d184661c9884371921f6937b89da6e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=93=AD=E5=9D=A4?= <10372463+ming-kun@user.noreply.gitee.com> Date: Thu, 30 Apr 2026 21:57:37 +0800 Subject: [PATCH] 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 --- .../__pycache__/price_match.cpython-39.pyc | Bin 35376 -> 35279 bytes app/amazon/price_match.py | 392 +++++++++--------- 2 files changed, 203 insertions(+), 189 deletions(-) diff --git a/app/amazon/__pycache__/price_match.cpython-39.pyc b/app/amazon/__pycache__/price_match.cpython-39.pyc index 818c7a4af48ad83c3edce2a6dae9af7c37387ac1..4941d37ebf55d409264939226a548592a01129a1 100644 GIT binary patch delta 4655 zcma)AdsLLi760bj2g|~)3(LatUfwJ(0R3bE-)!Tovf z%$+-T?rUZ_eSrT1<8vByIxPo3U*5UVG#pI0Pmr1Z69P;nd^&HF{W;hAhVjxiq1lRB`Lp*zKpQcId)9=Kvz$2PVtG?sl48mR&atC8t-H$ucL*s4y<24qBEO7yH;|1x{p z5W#Ng<7{Ox%xSf}k~b(c#7vY#&1;B-=oJwpix^-eRB0w!UQM(_10N+1G_P0q%4h5+ z`UW78EC|1HPfi#?*AOE|7)jCI8Q+2T^r8R!T}-2nD0Iaip6 zblV8m8w9bjQ3Gp?k0N2LJ3g0$`(BLyF;UJ(YYTQ5W5-^3!9R3j>sO)I2QCXV(q!zAagg>B;A8)K;gu>e2Mf_LY?85^|LZWwj5?mUx=b!h`q!<>F|f zWQ5rA@+pkeLX(=vMt-%NM;=YbRVj#?OW-^pnJfiCE~K!x%M$xiY1#mfxz;gX3a{ck zs&()5Mo1CON}5hXsd|8KR`nWT4UxEJ0;@7`7n*rQCFhW;r%EzP%EvhmFYc9aSL?K0 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!>B+hBj>5xVd{%yeDbedW*}|=juKCJRHdTgk(_O z!||VxypQCMNdABX6Ei8cbRD(c zR}Bu2^bWV8L~rxpj#UF4gK)8O6>-#&)VsF0x|J3@|Jz8g7tiF316ryaqzzZWA(@mp zl)!H3E~4;ipvt4Wny2Ob~g*N@wT zy$86YIqdhU;~^!$?c`(jyQ^2c^?UJcGoe$u)gx8~p+m_;>!A0WU30c{M z`mh+?8KI~ej;fw!+rPgL={t*SRNb?FqVKLkcV;(#G;s{&O`;a;Wk z-qcmav9m;`e5uA5QTTOq`6hDb^QAa8O-~A8PdMcFjqP(wOYG&no@v0|!{g(*3(@xk zmf&BW5*-088{nWXj1j*AF%*%hK0qu5Wgq3;$Q?H#WPO0pB_y$(E47FS_C&XpV>OZj zE(PNd;0Ca{?J2N&E@5T8gw-tol?C-JZA(L>wnl@X#=>#xLzpC8Qm@+gh2^BEM)-@G zRLMR&xSn*g)(18~!=HYj*@>mCG$7&cQ20*gPD>#%=8r%-VXGgkBAb}|!Sb3ebAdfB Z#D#)Pq%t4lsMn(7ucQAmHe4WP@*loIRYL#( diff --git a/app/amazon/price_match.py b/app/amazon/price_match.py index fc57491..c39b064 100644 --- a/app/amazon/price_match.py +++ b/app/amazon/price_match.py @@ -150,7 +150,18 @@ def calculate_target_price( # 分支 A:第一名是 Amazon US 卖家 (特殊强敌优先) price_1 = float(front_end_data.get("top_sellers")[0].get("price")) # 实际第一名价格 if "Amazon" in shop_name_1: - return RepricingLogic.situation_4_encounter_amz_us_1st(my_price,price_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) # 分支 B:不是 Amazon US,且目前是自己的购物车 elif is_my_buybox: @@ -360,10 +371,11 @@ class ChromeAmzone: self.tab.wait.doc_loaded(timeout=5,raise_err=False) # 3. 抓取数据 - print("正在抓取商品数据...") + print("===================正在抓取商品数据...====================") data = self._scrape_data() data['timestamp'] = datetime.now().strftime('%Y-%m-%d %H:%M:%S') print(f"数据抓取完成: {json.dumps(data)}") + print("======================================================") return data except Exception as e: @@ -658,161 +670,163 @@ class AmzonePriceMatch(AmamzonBase): # for sku_ele in sku_ls[0:2]: for sku_ele in sku_ls: - asin = sku_ele.ele( 'xpath:.//div[contains(@class,"JanusSplitBox-module__container")]//div[contains(@class,"JanusSplitBox-module__panel--") and contains(string(.),"ASIN")]/..//div[last()]', timeout=3).text print(f"【{self.mark_name}】ASIN {asin} 找到....") - # if asin in already_asin: - # print(f"【{self.mark_name}】{asin} 已经处理过了,跳过") - # continue - if asin in skip_asin: - yield (asin, { - "statu": "跳过,需要跳过的ASIN" - }) - continue - bottom_price_ele = sku_ele.eles('xpath:.//div[@data-test-id="LowestPrice"]/div[2]',timeout=5) - bottom_price = "" #初始化为空 - if len(bottom_price_ele) > 0: - try: - bottom_price_text = bottom_price_ele[0].text - # print("最低价格->>",bottom_price_text) - bottom_price = f"{sum(split_currency_values(bottom_price_text))}" - except Exception as e: - print("最低价提取失败",e) + try: + # if asin in already_asin: + # print(f"【{self.mark_name}】{asin} 已经处理过了,跳过") + # continue + if asin in skip_asin: + yield (asin, { + "statu": "跳过,需要跳过的ASIN" + }) + continue + bottom_price_ele = sku_ele.eles('xpath:.//div[@data-test-id="LowestPrice"]/div[2]',timeout=5) + bottom_price = "" #初始化为空 + if len(bottom_price_ele) > 0: + try: + bottom_price_text = bottom_price_ele[0].text + # print("最低价格->>",bottom_price_text) + bottom_price = f"{sum(split_currency_values(bottom_price_text))}" + except Exception as e: + print("最低价提取失败",e) - current_price_ele = sku_ele.eles('xpath:.//b[text()="价格"]/../..//kat-input',timeout=5) - if len(current_price_ele) > 0: - current_price = current_price_ele[0].attr("value") - print("获取到当前价格为 ->",current_price) - # 如果紫鸟里当前价格低于最低价则删除,否则跳过 - # if mode == "status" and miniprice_info.get(asin): - if miniprice_info.get(asin): - backend_price = float(miniprice_info.get(asin)) - if float(current_price) <= backend_price: - yield (asin, { - "statu": "跳过(当前价格低于或等于最低价)", - "currentPrice": current_price, - "minimumPrice": bottom_price, # 最低价格 - }) - continue + current_price_ele = sku_ele.eles('xpath:.//b[text()="价格"]/../..//kat-input',timeout=5) + if len(current_price_ele) > 0: + current_price = current_price_ele[0].attr("value") + print("获取到当前价格为 ->",current_price) + # 如果紫鸟里当前价格低于最低价则删除,否则跳过 + # if mode == "status" and miniprice_info.get(asin): + if miniprice_info.get(asin): + backend_price = float(miniprice_info.get(asin)) + if float(current_price) <= backend_price: + yield (asin, { + "statu": "跳过(当前价格低于或等于最低价)", + "currentPrice": current_price, + "minimumPrice": bottom_price, # 最低价格 + }) + continue - else: - print(f"{self.mark_name} 没有获取到当前价格") - yield (asin, { - "statu": "失败(没有获取到当前的价格)" - }) - continue + else: + print(f"{self.mark_name} 没有获取到当前价格") + yield (asin, { + "statu": "失败(没有获取到当前的价格)" + }) + continue - self.clear_tab() - detail_url_ele = sku_ele.ele('xpath:.//div[contains(@class,"ProductDetails-module__titleContainer")]//a') - # detail_url_ele.click() - detail_url = detail_url_ele.attr("href") - print("详情链接",detail_url) - # time.sleep(1) - for _ in range(10): - try: - new_tab = self.browser.new_tab(url=detail_url) - print("获取新标签页成功",new_tab) + self.clear_tab() + detail_url_ele = sku_ele.ele('xpath:.//div[contains(@class,"ProductDetails-module__titleContainer")]//a') + # detail_url_ele.click() + detail_url = detail_url_ele.attr("href") + print("详情链接",detail_url) + # time.sleep(1) + for _ in range(10): + try: + new_tab = self.browser.new_tab(url=detail_url) + print("获取新标签页成功",new_tab) + time.sleep(1) + break + except Exception as e: + time.sleep(1) + pass + chrome = ChromeAmzone(tab=new_tab) + front_end_data = chrome.run(country=current_country) + chrome.close() + self.clear_tab() + print(self.mark_name,"亚马逊前台抓取到数据",front_end_data) + if front_end_data is None or len(front_end_data.get("top_sellers")) == 0: + yield (asin, { + "statu": "失败(第一名获取失败,请检查卖家精灵是否启用)", + "currentPrice": current_price, + }) + continue + + cart_seller = front_end_data.get("cart_seller") + if cart_seller == current_shop_name and len(front_end_data.get("top_sellers"))< 2: + yield (asin, { + "statu": "跳过(自己的购物车,只有第一名)", + "currentPrice": current_price, + }) + continue + + recommend_price_ele= sku_ele.eles('xpath:.//div[@data-test-id="FeaturedOfferPrice"]/div[2]',timeout=5) + if len(recommend_price_ele) > 0: + try: + price_text = recommend_price_ele[0].text + # print("推荐价格 ->>",price_text) + recommend_price,shipping_fee = split_currency_values(price_text) + except Exception as e: + print("推荐价格和运费提取失败 ->>",e) + recommend_price, shipping_fee = 0, 0 + else: + print(f"{self.mark_name} 没有查找有推荐价格和运费") + recommend_price,shipping_fee = 0,0 + + adjust_prices = calculate_target_price( + front_end_data, float(current_price), current_shop_name, + recommend_price, shipping_fee + ) + # adjust_prices = 236.56 + + print(asin,"-->>",f"【逻辑计算后的价格】",adjust_prices) + if adjust_prices is not None and adjust_prices != float(current_price): + #修改价格 + print("准备填入的原始值:",adjust_prices) + adjust_prices = round(adjust_prices, 2) + print("保留两位小数后的::",adjust_prices) + self.tab.actions.click(current_price_ele[0]) time.sleep(1) - break - except Exception as e: + current_price_ele[0].input(f"{adjust_prices}", clear=True) time.sleep(1) - pass - chrome = ChromeAmzone(tab=new_tab) - front_end_data = chrome.run(country=current_country) - chrome.close() - self.clear_tab() - print(self.mark_name,"亚马逊前台抓取到数据",front_end_data) - if front_end_data is None or len(front_end_data.get("top_sellers")) == 0: - yield (asin, { - "statu": "失败(第一名获取失败,请检查卖家精灵是否启用)", - "currentPrice": current_price, - }) + # current_price_ele[0].sr('xpath:.//inpu[@part="input"]').input(f"{adjust_prices}",clear=True) + out_focus = sku_ele.ele('xpath:.//b[text()="价格"]/../..//kat-label',timeout=5) + out_focus.click() + time.sleep(1) + save_all_btn = self.tab.ele('xpath://kat-button[@label="保存所有"]', timeout=10) + save_all_btn.wait.displayed(timeout=10, raise_err=False) + save_all_btn.click() + save_all_btn.wait.deleted(timeout=10, raise_err=False) + recommendedPrice = recommend_price + shipping_fee + price_1 = float(front_end_data.get("top_sellers")[0].get("price")) if len(front_end_data.get("top_sellers")) >= 2 else "" # 实际第一名价格 + price_2 = float(front_end_data.get("top_sellers")[1].get("price")) if len(front_end_data.get("top_sellers")) >= 2 else "" # 实际第二名价格 + cartShopName = front_end_data.get("cart_seller") + yield (asin,{ + "statu" : "改价成功", + "currentPrice" : current_price, + "recommendedPrice" : f"{recommendedPrice}", + "minimumPrice" : f"{miniprice_info.get(asin)}" if miniprice_info.get(asin) else "",#bottom_price, #最低价格 + "firstPlace": price_1, + "secondPlace": price_2, + "cartShopName" : cartShopName, + "shippingFee" : f"{shipping_fee}", + "priceChangePrice" : f"{adjust_prices}", + "priceChangeStatus" : "改价成功", + }) + else: + recommendedPrice = recommend_price + shipping_fee + price_1 = float(front_end_data.get("top_sellers")[0].get("price")) if len( + front_end_data.get("top_sellers")) >= 2 else "" # 实际第一名价格 + price_2 = float(front_end_data.get("top_sellers")[1].get("price")) if len( + front_end_data.get("top_sellers")) >= 2 else "" # 实际第二名价格 + cartShopName = front_end_data.get("cart_seller") + yield (asin, { + "statu": "跳过,无需改价", + "currentPrice": current_price, + "recommendedPrice": f"{recommendedPrice}", + # "minimumPrice": bottom_price, # 最低价格 + "minimumPrice": f"{miniprice_info.get(asin)}" if miniprice_info.get(asin) else "", + "firstPlace": price_1, + "secondPlace": price_2, + "cartShopName": cartShopName, + "shippingFee": f"{shipping_fee}", + "priceChangeStatus": "跳过,无需改价", + "priceChangePrice": f"{adjust_prices}".replace("None",""), + }) + except Exception as e: + print(f"{asin},操作出错,{e}") continue - - cart_seller = front_end_data.get("cart_seller") - if cart_seller == current_shop_name and len(front_end_data.get("top_sellers"))< 2: - yield (asin, { - "statu": "跳过(自己的购物车,只有第一名)", - "currentPrice": current_price, - }) - continue - - recommend_price_ele= sku_ele.eles('xpath:.//div[@data-test-id="FeaturedOfferPrice"]/div[2]',timeout=5) - if len(recommend_price_ele) > 0: - try: - price_text = recommend_price_ele[0].text - # print("推荐价格 ->>",price_text) - recommend_price,shipping_fee = split_currency_values(price_text) - except Exception as e: - print("推荐价格和运费提取失败 ->>",e) - recommend_price, shipping_fee = 0, 0 - else: - print(f"{self.mark_name} 没有查找有推荐价格和运费") - recommend_price,shipping_fee = 0,0 - - adjust_prices = calculate_target_price( - front_end_data, float(current_price), current_shop_name, - recommend_price, shipping_fee - ) - # adjust_prices = 236.56 - - print(asin,"-->>",f"【逻辑计算后的价格】",adjust_prices) - if adjust_prices is not None and adjust_prices != float(current_price): - #修改价格 - print("准备填入的原始值:",adjust_prices) - adjust_prices = round(adjust_prices, 2) - print("保留两位小数后的::",adjust_prices) - self.tab.actions.click(current_price_ele[0]) - time.sleep(1) - current_price_ele[0].input(f"{adjust_prices}", clear=True) - time.sleep(1) - # current_price_ele[0].sr('xpath:.//inpu[@part="input"]').input(f"{adjust_prices}",clear=True) - out_focus = sku_ele.ele('xpath:.//b[text()="价格"]/../..//kat-label',timeout=5) - out_focus.click() - time.sleep(1) - save_all_btn = self.tab.ele('xpath://kat-button[@label="保存所有"]', timeout=10) - save_all_btn.wait.displayed(timeout=10, raise_err=False) - save_all_btn.click() - save_all_btn.wait.deleted(timeout=10, raise_err=False) - recommendedPrice = recommend_price + shipping_fee - price_1 = float(front_end_data.get("top_sellers")[0].get("price")) if len(front_end_data.get("top_sellers")) >= 2 else "" # 实际第一名价格 - price_2 = float(front_end_data.get("top_sellers")[1].get("price")) if len(front_end_data.get("top_sellers")) >= 2 else "" # 实际第二名价格 - cartShopName = front_end_data.get("cart_seller") - yield (asin,{ - "statu" : "改价成功", - "currentPrice" : current_price, - "recommendedPrice" : f"{recommendedPrice}", - "minimumPrice" : f"{miniprice_info.get(asin)}" if miniprice_info.get(asin) else "",#bottom_price, #最低价格 - "firstPlace": price_1, - "secondPlace": price_2, - "cartShopName" : cartShopName, - "shippingFee" : f"{shipping_fee}", - "priceChangePrice" : f"{adjust_prices}", - "priceChangeStatus" : "改价成功", - }) - else: - recommendedPrice = recommend_price + shipping_fee - price_1 = float(front_end_data.get("top_sellers")[0].get("price")) if len( - front_end_data.get("top_sellers")) >= 2 else "" # 实际第一名价格 - price_2 = float(front_end_data.get("top_sellers")[1].get("price")) if len( - front_end_data.get("top_sellers")) >= 2 else "" # 实际第二名价格 - cartShopName = front_end_data.get("cart_seller") - yield (asin, { - "statu": "跳过,无需改价", - "currentPrice": current_price, - "recommendedPrice": f"{recommendedPrice}", - # "minimumPrice": bottom_price, # 最低价格 - "minimumPrice": f"{miniprice_info.get(asin)}" if miniprice_info.get(asin) else "", - "firstPlace": price_1, - "secondPlace": price_2, - "cartShopName": cartShopName, - "shippingFee": f"{shipping_fee}", - "priceChangeStatus": "跳过,无需改价", - "priceChangePrice": f"{adjust_prices}".replace("None",""), - }) - already_asin.add(asin) # 判断是否存在需要翻页的情况 @@ -1417,49 +1431,49 @@ class PriceTask: if __name__ == '__main__': # 使用示例 - # user_info = { - # "company": "尾号5578的公司115", - # "username": "自动化_Robot", - # "password": "#20zsg25" - # } - # shop_name = "刘建煌" - # country = "法国" - # kill_process('v6') - # driver = AmzonePriceMatch(user_info) - # browser = driver.open_shop(shop_name) - # sw_suc = driver.SwitchingCountries(country) - # driver.SwitchPage() - # risk_listing_filter = "Active" - # _shopMallName = "Jianhuang 888" - # ap_asin ="B0F25Y52PH" - # skip_asin = [] - # for _ in range(3): - # try: - # sku_ls = driver.search(filter_type=risk_listing_filter) - # break - # except Exception as e: - # print(e) - # driver.tab.refresh() - # if len(sku_ls) > 0: - # print("有数据,开始操作") - # for asin, status in driver.run_page_action( - # current_shop_name=_shopMallName, - # appoint_asin=ap_asin,skip_asin=skip_asin,mode="asin" - # ): - # print(f"ASIN {asin} 的处理结果: {status}") - # print("已完成操作") + user_info = { + "company": "尾号5578的公司115", + "username": "自动化_Robot", + "password": "#20zsg25" + } + shop_name = "刘建煌" + country = "法国" + kill_process('v6') + driver = AmzonePriceMatch(user_info) + browser = driver.open_shop(shop_name) + sw_suc = driver.SwitchingCountries(country) + driver.SwitchPage() + risk_listing_filter = "Active" + _shopMallName = "Jianhuang 888" + ap_asin ="B0F25Y52PH" + skip_asin = [] + for _ in range(3): + try: + sku_ls = driver.search(filter_type=risk_listing_filter) + break + except Exception as e: + print(e) + driver.tab.refresh() + if len(sku_ls) > 0: + print("有数据,开始操作") + for asin, status in driver.run_page_action( + current_shop_name=_shopMallName, + appoint_asin=ap_asin,skip_asin=skip_asin,mode="asin" + ): + print(f"ASIN {asin} 的处理结果: {status}") + 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'} - - current_Price = 52.51 - current_shop_name = "Jianhuang 888" - recommended_price = 52.51 - recommended_shipping =0.0 - res = calculate_target_price( - front_end_data, current_Price, current_shop_name, - recommended_price, recommended_shipping - ) - print(res) + # 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_shop_name = "Jianhuang 888" + # recommended_price = 52.51 + # recommended_shipping =0.0 + # res = calculate_target_price( + # front_end_data, current_Price, current_shop_name, + # recommended_price, recommended_shipping + # ) + # 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}}