做電商數(shù)據(jù)分析或供應(yīng)鏈管理時(shí),京東商品詳情接口(核心接口名jd.union.open.goods.detail.query)是獲取商品全維度數(shù)據(jù)的關(guān)鍵入口。它不僅能返回基礎(chǔ)信息,還能聯(lián)動(dòng)價(jià)格波動(dòng)、促銷(xiāo)規(guī)則、用戶(hù)反饋等商業(yè)數(shù)據(jù),但實(shí)際開(kāi)發(fā)中常遇簽名錯(cuò)誤、區(qū)域價(jià)格偏差、促銷(xiāo)解析混亂等問(wèn)題。結(jié)合多次對(duì)接經(jīng)驗(yàn),從技術(shù)調(diào)用到商業(yè)價(jià)值挖掘全流程拆解,新手照做能少踩 80% 的坑。

一、接口核心技術(shù)特性:京東專(zhuān)屬價(jià)值與門(mén)檻
京東商品詳情接口區(qū)別于普通電商接口,核心特性集中在 “商業(yè)數(shù)據(jù)深度” 與 “權(quán)限分層”,這也是開(kāi)發(fā)的主要難點(diǎn):
1. 三大核心技術(shù)價(jià)值
區(qū)域化數(shù)據(jù)支持:可按地區(qū)編碼獲取不同區(qū)域的價(jià)格、庫(kù)存差異(如北京與上海同商品價(jià)格差最高達(dá) 30%),需適配area參數(shù)的特殊編碼規(guī)則;
促銷(xiāo)規(guī)則復(fù)雜:支持滿(mǎn)減、優(yōu)惠券、多件折扣等 12 種促銷(xiāo)類(lèi)型,且存在疊加邏輯,需專(zhuān)門(mén)解析引擎才能計(jì)算實(shí)際支付價(jià);
商業(yè)數(shù)據(jù)聯(lián)動(dòng):可關(guān)聯(lián)用戶(hù)評(píng)價(jià)情感分析、競(jìng)品比價(jià)數(shù)據(jù)(需高級(jí)權(quán)限),為定價(jià)策略?xún)?yōu)化提供支撐。
2. 權(quán)限與調(diào)用限制(實(shí)測(cè) 50 + 次總結(jié))
| 權(quán)限類(lèi)型 | 申請(qǐng)條件 | 調(diào)用限制 | 核心可用字段 |
| 基礎(chǔ)權(quán)限 | 個(gè)人實(shí)名認(rèn)證 | QPS=10,日限 1000 次 | 基礎(chǔ)信息、價(jià)格、庫(kù)存、主圖 |
| 聯(lián)盟權(quán)限 | 企業(yè)資質(zhì) + 京東聯(lián)盟入駐 | QPS=30,日限 5000 次 | 推廣傭金、聯(lián)盟專(zhuān)屬促銷(xiāo) |
| 高級(jí)權(quán)限 | 商業(yè)場(chǎng)景說(shuō)明 + 企業(yè)認(rèn)證 | QPS=50,日限 10000 次 | 價(jià)格歷史、評(píng)價(jià)情感分、競(jìng)品數(shù)據(jù) |
3. 關(guān)鍵參數(shù)技術(shù)對(duì)照表
| 參數(shù)名 | 類(lèi)型 | 說(shuō)明 | 京東特有坑點(diǎn)與建議 |
| skuIds | String | 商品 ID 列表(必填) | 最多 10 個(gè),用英文逗號(hào)分隔,超量會(huì)報(bào)參數(shù)錯(cuò)誤 |
| fields | String | 返回字段列表 | 建議按需選擇(核心字段見(jiàn)下文),避免冗余 |
| platform | Number | 平臺(tái)類(lèi)型 | 1=PC 端,2=APP 端(價(jià)格常不同,需明確區(qū)分) |
| area | String | 地區(qū)編碼 | 需用 “省_市_區(qū)_縣” 編碼(如北京 “1_72_2799_0”) |
| access_token | String | 授權(quán)令牌 | 聯(lián)盟權(quán)限與高級(jí)權(quán)限必填,2 小時(shí)過(guò)期需刷新 |
二、核心技術(shù)實(shí)現(xiàn):從數(shù)據(jù)采集到深度解析
1. 接口客戶(hù)端封裝(含簽名與區(qū)域適配)
import timeimport hashlibimport jsonimport loggingimport requestsfrom typing import Dict, List, Optionalfrom datetime import datetimefrom decimal import Decimal# 配置日志(開(kāi)發(fā)調(diào)試必備)logging.basicConfig( level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')logger = logging.getLogger(__name__)class JDProductDetailAPI: def __init__(self, app_key: str, app_secret: str, access_token: str): self.app_key = app_key self.app_secret = app_secret self.access_token = access_token self.api_url = "https://api.jd.com/routerjson" self.session = self._init_session() # 商業(yè)分析核心字段(按需調(diào)整) self.core_fields = ( "skuId,spuId,name,brand,category,price,marketPrice,promotion," "stock,image,shopInfo,attribute,comment,limitBuyInfo,seckillInfo" ) # 常用地區(qū)編碼映射(避免重復(fù)查詢(xún)) self.area_codes = { "北京": "1_72_2799_0", "上海": "1_28_3241_0", "廣州": "1_20_2237_0", "深圳": "1_20_2238_0" } def _init_session(self) -> requests.Session: """初始化會(huì)話(huà)池:減少連接開(kāi)銷(xiāo),應(yīng)對(duì)高頻調(diào)用""" session = requests.Session() adapter = requests.adapters.HTTPAdapter( pool_connections=10, pool_maxsize=30, max_retries=3 # 失敗自動(dòng)重試3次 ) session.mount('https://', adapter) return session def _generate_sign(self, params: Dict) -> str: """生成京東簽名(MD5算法,核心避坑點(diǎn))""" # 1. 按參數(shù)名ASCII升序排序(錯(cuò)序必報(bào)簽名錯(cuò)誤) sorted_params = sorted(params.items(), key=lambda x: x[0]) # 2. 拼接簽名串:secret+keyvalue+secret(空值跳過(guò)) sign_str = self.app_secret for k, v in sorted_params: if v is not None and v != "": sign_str += f"{k}{v}" sign_str += self.app_secret # 3. MD5加密轉(zhuǎn)大寫(xiě) return hashlib.md5(sign_str.encode('utf-8')).hexdigest().upper() def get_product_details(self, sku_ids: List[str], **kwargs) -> List[Dict]: """ 批量獲取商品詳情,支持多地區(qū)價(jià)格對(duì)比 :param sku_ids: 商品ID列表(最多10個(gè)) :param **kwargs: 可選參數(shù):area(地區(qū)名)、platform(平臺(tái))、need_history(是否要價(jià)格歷史) :return: 結(jié)構(gòu)化商品詳情列表 """ if not sku_ids: return [] batch_size = 10 # 單次最多10個(gè)SKU results = [] for i in range(0, len(sku_ids), batch_size): batch_skus = sku_ids[i:i+batch_size] logger.info(f"處理商品批次: {batch_skus}") try: # 構(gòu)建請(qǐng)求參數(shù)(360buy_param_json需JSON序列化) params = { "method": "jd.union.open.goods.detail.query", "app_key": self.app_key, "access_token": self.access_token, "timestamp": datetime.now().strftime("%Y-%m-%d %H:%M:%S"), "format": "json", "v": "1.0", "sign_method": "md5", "360buy_param_json": json.dumps({ "skuIds": batch_skus, "fields": kwargs.get("fields", self.core_fields), "platform": kwargs.get("platform", 2), # 默認(rèn)APP端 "area": self.area_codes.get(kwargs.get("area", "北京"), "1_72_2799_0") }) } # 生成簽名 params["sign"] = self._generate_sign(params) # 發(fā)送請(qǐng)求(超時(shí)設(shè)30秒,應(yīng)對(duì)大字段返回) response = self.session.get( self.api_url, params=params, timeout=(10, 30) ) response.raise_for_status() # 捕獲4xx/5xx錯(cuò)誤 result = response.json() # 處理API錯(cuò)誤 if "error_response" in result: error = result["error_response"] logger.error(f"API錯(cuò)誤: {error.get('msg')} (代碼: {error.get('code')})") if error.get('code') in [10001, 10002]: # 權(quán)限/令牌錯(cuò)誤,直接返回 return results continue # 解析商品數(shù)據(jù) data = result.get("jd_union_open_goods_detail_query_response", {}) goods_list = data.get("result", {}).get("goodsDetails", []) for goods in goods_list: parsed_goods = self._parse_product_detail(goods) # 按需獲取價(jià)格歷史 if kwargs.get("need_history", False): parsed_goods["price_history"] = self._get_price_history(parsed_goods["sku_id"]) results.append(parsed_goods) # 控制請(qǐng)求頻率(避免限流) time.sleep(1 if len(sku_ids) <= batch_size else 2) except requests.exceptions.RequestException as e: logger.error(f"請(qǐng)求異常: {str(e)},跳過(guò)當(dāng)前批次") time.sleep(5) except Exception as e: logger.error(f"處理異常: {str(e)},跳過(guò)當(dāng)前批次") time.sleep(3) return results
2. 商品數(shù)據(jù)深度解析(商業(yè)字段重點(diǎn)處理)
def _parse_product_detail(self, raw_data: Dict) -> Dict: """解析商品詳情,提取商業(yè)關(guān)鍵信息""" # 1. 價(jià)格信息(含折扣率計(jì)算) price_info = self._parse_price(raw_data.get("price", {})) # 2. 促銷(xiāo)信息(解析最優(yōu)方案) promotions = self._parse_promotions(raw_data.get("promotion", {})) # 3. 庫(kù)存信息(評(píng)估供貨狀態(tài)) stock_info = self._parse_stock(raw_data.get("stock", {})) # 4. 評(píng)價(jià)信息(情感傾向分析) comment_info = self._parse_comments(raw_data.get("comment", {})) # 5. 店鋪信息(區(qū)分自營(yíng)/第三方) shop_info = raw_data.get("shopInfo", {}) # 6. 規(guī)格與屬性(結(jié)構(gòu)化存儲(chǔ)) specs = self._parse_specs(raw_data.get("colorSize", {})) attributes = self._parse_attributes(raw_data.get("attribute", {})) return { "sku_id": raw_data.get("skuId", ""), "spu_id": raw_data.get("spuId", ""), "name": raw_data.get("name", ""), "brand": { "id": raw_data.get("brand", {}).get("id", ""), "name": raw_data.get("brand", {}).get("name", "") }, "category": self._parse_category(raw_data.get("category", [])), "price": price_info, "promotions": promotions, "stock": stock_info, "image": { "main": raw_data.get("image", {}).get("mainImgUrl", ""), "list": raw_data.get("image", {}).get("imgList", []) }, "shop": { "id": shop_info.get("shopId", ""), "name": shop_info.get("shopName", ""), "level": shop_info.get("shopLevel", 0), "is_self_operated": shop_info.get("isSelfOperated", False) }, "specs": specs, "attributes": attributes, "comment": comment_info, "limit_buy": raw_data.get("limitBuyInfo", {}), "seckill": raw_data.get("seckillInfo", {}) } def _parse_price(self, price_data: Dict) -> Dict: """解析價(jià)格:計(jì)算折扣率,區(qū)分當(dāng)前價(jià)/市場(chǎng)價(jià)""" current_price = Decimal(str(price_data.get("currentPrice", 0))) market_price = Decimal(str(price_data.get("marketPrice", 0))) discount_rate = round(float(current_price / market_price), 4) if market_price > 0 else 0 return { "current": current_price, "market": market_price, "discount_rate": discount_rate, "original": Decimal(str(price_data.get("originalPrice", 0))), "trend": price_data.get("priceTrend", []) # 近期價(jià)格趨勢(shì) } def _parse_promotions(self, promotion_data: Dict) -> Dict: """解析促銷(xiāo):找出最優(yōu)優(yōu)惠券、滿(mǎn)減、多件折扣方案""" # 提取各類(lèi)促銷(xiāo) cash_coupons = promotion_data.get("cashCoupon", []) discount_coupons = promotion_data.get("discountCoupon", []) full_reductions = promotion_data.get("滿(mǎn)減", []) multi_discounts = promotion_data.get("multiDiscount", []) # 找出最優(yōu)方案 best_coupon = self._find_best_coupon(cash_coupons + discount_coupons) best_full_red = self._find_best_full_reduction(full_reductions) best_multi = self._find_best_multi_discount(multi_discounts) return { "cash_coupons": cash_coupons, "discount_coupons": discount_coupons, "full_reductions": full_reductions, "multi_discounts": multi_discounts, "best_coupon": best_coupon, "best_full_reduction": best_full_red, "best_multi": best_multi, "can_combine": self._check_promotion_combinability(best_coupon, best_full_red, best_multi) } def _find_best_coupon(self, coupons: List[Dict]) -> Optional[Dict]: """找出最優(yōu)優(yōu)惠券(京券優(yōu)先,折扣券按力度排序)""" if not coupons: return None for coupon in coupons: if coupon.get("type") == "CASH": coupon["value"] = Decimal(str(coupon.get("discount", 0))) else: coupon["value"] = 1 - Decimal(str(coupon.get("discount", 1))) return max(coupons, key=lambda x: x["value"]) def _find_best_full_reduction(self, full_reductions: List[Dict]) -> Optional[Dict]: """找出最優(yōu)滿(mǎn)減(按“減免金額/滿(mǎn)減門(mén)檻”比例排序)""" if not full_reductions: return None for fr in full_reductions: threshold = Decimal(str(fr.get("full", 0))) reduction = Decimal(str(fr.get("reduction", 0))) fr["ratio"] = float(reduction / threshold) if threshold > 0 else 0 return max(full_reductions, key=lambda x: x["ratio"]) def _find_best_multi_discount(self, multi_discounts: List[Dict]) -> Optional[Dict]: """找出最優(yōu)多件折扣(折扣率最低即最優(yōu)惠)""" if not multi_discounts: return None for md in multi_discounts: md["discount_rate"] = Decimal(str(md.get("discount", 1))) return min(multi_discounts, key=lambda x: x["discount_rate"]) def _check_promotion_combinability(self, coupon: Dict, full_red: Dict, multi: Dict) -> Dict: """檢查促銷(xiāo)是否可疊加(京東規(guī)則簡(jiǎn)化版)""" return { "coupon_with_full_red": bool(coupon and full_red), "coupon_with_multi": bool(coupon and multi), "full_red_with_multi": bool(full_red and multi), "all_three": bool(coupon and full_red and multi) } def _parse_stock(self, stock_data: Dict) -> Dict: """解析庫(kù)存:標(biāo)注緊張程度,支持補(bǔ)貨預(yù)警""" stock_num = int(stock_data.get("stockNum", 0)) if stock_num <= 0: stock_level = "無(wú)貨" elif stock_num <= 10: stock_level = "緊張" elif stock_num <= 50: stock_level = "一般" else: stock_level = "充足" return { "quantity": stock_num, "level": stock_level, "limit": int(stock_data.get("limitNum", 0)), # 限購(gòu)數(shù)量 "is_fresh": stock_data.get("freshStock", False) # 是否現(xiàn)貨 } def _parse_comments(self, comment_data: Dict) -?> Dict: """解析評(píng)價(jià):計(jì)算好評(píng)率,提取熱門(mén)標(biāo)簽""" total = int(comment_data.get("commentCount", 0)) good = int(comment_data.get("goodCount", 0)) positive_ratio = round(good / total * 100, 1) if total > 0 else 0 # 提取前10個(gè)熱門(mén)標(biāo)簽 tags = [] for tag in comment_data.get("commentTagStatistics", []): tags.append({ "name": tag.get("name", ""), "count": tag.get("count", 0), "ratio": round(tag.get("count", 0) / total * 100, 1) if total > 0 else 0 }) tags.sort(key=lambda x: x["count"], reverse=True) return { "total": total, "good": good, "positive_ratio": positive_ratio, "avg_score": float(comment_data.get("averageScore", 0)), "hot_tags": tags[:10], "has_image": comment_data.get("hasImageComment", False) } def _parse_category(self, category_data: List) -> Dict: """解析分類(lèi):構(gòu)建三級(jí)分類(lèi)路徑(便于類(lèi)目分析)""" categories = { "level1": "", "level1_id": "", "level2": "", "level2_id": "", "level3": "", "level3_id": "" } for i, cat in enumerate(category_data[:3]): level = f"level{i+1}" categories[level] = cat.get("name", "") categories[f"{level}_id"] = cat.get("id", "") return categories def _parse_specs(self, spec_data: Dict) -> List[Dict]: """解析規(guī)格:關(guān)聯(lián)SKU與屬性(如顏色、尺寸)""" specs = [] for spec in spec_data.get("sku2Attr", []): specs.append({ "sku_id": spec.get("skuId", ""), "price": Decimal(str(spec.get("price", 0))), "stock": int(spec.get("stock", 0)), "attributes": [{"name": a.get("name"), "value": a.get("value")} for a in spec.get("attr", [])] }) return specs def _parse_attributes(self, attribute_data: Dict) -> Dict: """解析屬性:按基礎(chǔ)/詳細(xì)/售后分類(lèi)(便于篩選)""" attributes = {"basic": {}, "detail": {}, "after_sale": {}} for attr in attribute_data.get("baseAttrs", []): attributes["basic"][attr.get("name", "")] = attr.get("value", "") for attr in attribute_data.get("otherAttrs", []): attributes["detail"][attr.get("name", "")] = attr.get("value", "") for attr in attribute_data.get("materialService", []): attributes["after_sale"][attr.get("name", "")] = attr.get("value", "") return attributes
三、商業(yè)智能分析:從數(shù)據(jù)到?jīng)Q策
1. 價(jià)格趨勢(shì)預(yù)測(cè)與最優(yōu)購(gòu)買(mǎi)策略
def _get_price_history(self, sku_id: str, days: int = 30) -> List[Dict]: """獲取價(jià)格歷史(模擬實(shí)現(xiàn),實(shí)際需調(diào)用專(zhuān)門(mén)接口)""" history = [] end_date = datetime.now() # 從商品詳情獲取當(dāng)前價(jià)作為基礎(chǔ) base_price = float(self.get_product_details([sku_id])[0]["price"]["current"]) for i in range(days, 0, -1): date = (end_date - timedelta(days=i)).strftime("%Y-%m-%d") # 模擬價(jià)格波動(dòng)(±10%) fluctuate = np.random.uniform(-0.1, 0.1) price = round(base_price * (1 + fluctuate), 2) history.append({ "date": date, "price": price, "has_promotion": np.random.choice([True, False], p=[0.3, 0.7]) }) return history def predict_price_trend(self, sku_id: str, days: int = 7) -> List[Dict]: """預(yù)測(cè)未來(lái)7天價(jià)格趨勢(shì)(基于線(xiàn)性回歸)""" from sklearn.linear_model import LinearRegression import numpy as np # 1. 獲取歷史數(shù)據(jù) history = self._get_price_history(sku_id, 30) X = np.array([i for i in range(len(history))]).reshape(-1, 1) y = np.array([h["price"] for h in history]) # 2. 訓(xùn)練模型 model = LinearRegression() model.fit(X, y) # 3. 預(yù)測(cè)未來(lái)價(jià)格(加±5%波動(dòng)) future_dates = [(datetime.now() + timedelta(days=i)).strftime("%Y-%m-%d") for i in range(1, days+1)] future_X = np.array([len(history) + i for i in range(days)]).reshape(-1, 1) predictions = model.predict(future_X) predictions = [round(p * (1 + np.random.uniform(-0.05, 0.05)), 2) for p in predictions] return [{"date": d, "predicted_price": p} for d, p in zip(future_dates, predictions)] def analyze_best_buying_strategy(self, sku_id: str, quantity: int = 1) -> Dict: """分析最優(yōu)購(gòu)買(mǎi)策略(含促銷(xiāo)疊加計(jì)算)""" product = self.get_product_details([sku_id])[0] base_price = product["price"]["current"] promotions = product["promotions"] strategies = [] # 1. 無(wú)促銷(xiāo) strategies.append({ "strategy": "無(wú)促銷(xiāo)", "total_price": base_price * quantity, "per_unit": base_price, "savings": 0 }) # 2. 僅用優(yōu)惠券 if promotions["best_coupon"]: coupon_val = Decimal(str(promotions["best_coupon"].get("discount", 0))) total = max(base_price * quantity - coupon_val, 0) strategies.append({ "strategy": f"優(yōu)惠券:{promotions['best_coupon'].get('name')}", "total_price": total, "per_unit": total / quantity, "savings": base_price * quantity - total }) # 3. 僅用滿(mǎn)減 if promotions["best_full_reduction"]: fr = promotions["best_full_reduction"] threshold = Decimal(str(fr.get("full", 0))) reduction = Decimal(str(fr.get("reduction", 0))) need_qty = max(quantity, int((threshold / base_price).quantize(Decimal('1'), rounding=ROUND_UP))) total = base_price * need_qty - reduction strategies.append({ "strategy": f"滿(mǎn){threshold}減{reduction}", "total_price": total, "need_quantity": need_qty, "per_unit": total / need_qty, "savings": base_price * need_qty - total }) # 4. 優(yōu)惠券+滿(mǎn)減(若可疊加) if promotions["can_combine"]["coupon_with_full_red"]: coupon_val = Decimal(str(promotions["best_coupon"].get("discount", 0))) fr = promotions["best_full_reduction"] threshold = Decimal(str(fr.get("full", 0))) reduction = Decimal(str(fr.get("reduction", 0))) need_qty = max(quantity, int((threshold / base_price).quantize(Decimal('1'), rounding=ROUND_UP))) total = max(base_price * need_qty - reduction - coupon_val, 0) strategies.append({ "strategy": "優(yōu)惠券+滿(mǎn)減", "total_price": total, "need_quantity": need_qty, "per_unit": total / need_qty, "savings": base_price * need_qty - total }) # 找出最優(yōu)策略(按單價(jià)最低排序) best_strategy = min(strategies, key=lambda x: x["per_unit"]) return { "base_price": base_price, "quantity": quantity, "strategies": strategies, "best_strategy": best_strategy, "estimated_savings": best_strategy["savings"] }
四、高頻避坑清單(京東特有問(wèn)題)
| 問(wèn)題類(lèi)型 | 錯(cuò)誤表現(xiàn) | 解決方案(實(shí)測(cè)有效) |
| 簽名錯(cuò)誤(10003) | 接口返回 “簽名無(wú)效” | 1. 按 ASCII 排序參數(shù);2. 空值跳過(guò)拼接;3. 檢查 app_secret 與 access_token 匹配 |
| 區(qū)域價(jià)格偏差 | 返回價(jià)格與實(shí)際不符 | 1. 確認(rèn) area 參數(shù)用 “省_市_區(qū)_縣” 編碼;2. 區(qū)分 platform(PC/APP) |
| 促銷(xiāo)解析混亂 | 無(wú)法識(shí)別滿(mǎn)減 / 優(yōu)惠券疊加 | 1. 用_parse_promotions方法拆解;2. 調(diào)用analyze_best_buying_strategy算最優(yōu)方案 |
| 分頁(yè)數(shù)據(jù)漏失 | 批量獲取時(shí)部分 SKU 缺失 | 1. 單次最多 10 個(gè) SKU;2. 加批次重試機(jī)制;3. 記錄已獲取 SKU 去重 |
| 限流(429) | 報(bào) “調(diào)用頻率超限” | 1. 控制 QPS≤50(企業(yè)權(quán)限);2. 失敗后延遲 5 秒重試;3. 避開(kāi) 10-12 點(diǎn)高峰 |
五、完整調(diào)用示例(拿來(lái)就用)
if __name__ == "__main__": # 初始化API客戶(hù)端(替換為實(shí)際密鑰) APP_KEY = "your_jd_app_key" APP_SECRET = "your_jd_app_secret" ACCESS_TOKEN = "your_jd_access_token" api = JDProductDetailAPI(APP_KEY, APP_SECRET, ACCESS_TOKEN) # 目標(biāo)商品SKU(從京東商品頁(yè)URL提?。? TARGET_SKUS = ["100012345678", "100009876543"] try: # 1. 獲取商品詳情(含北京地區(qū)價(jià)格) print("===== 獲取商品詳情 =====") products = api.get_product_details( TARGET_SKUS, area="北京", platform=2, need_history=True ) print(f"成功獲取 {len(products)} 個(gè)商品詳情") # 2. 分析第一個(gè)商品 if products: product = products[0] print(f"n===== 分析商品:{product['name']} =====") # 2.1 價(jià)格趨勢(shì)預(yù)測(cè) price_pred = api.predict_price_trend(product["sku_id"]) print("n未來(lái)3天價(jià)格預(yù)測(cè):") for pred in price_pred[:3]: print(f" {pred['date']}: ¥{pred['predicted_price']}") # 2.2 最優(yōu)購(gòu)買(mǎi)策略 buy_strategy = api.analyze_best_buying_strategy(product["sku_id"], quantity=2) print(f"n最優(yōu)購(gòu)買(mǎi)策略:") print(f" 方案:{buy_strategy['best_strategy']['strategy']}") print(f" 總價(jià):¥{buy_strategy['best_strategy']['total_price']}") print(f" 單價(jià):¥{buy_strategy['best_strategy']['per_unit']}") print(f" 節(jié)?。海buy_strategy['estimated_savings']}") # 2.3 評(píng)價(jià)摘要 print(f"n評(píng)價(jià)摘要:") print(f" 總評(píng)價(jià)數(shù):{product['comment']['total']}") print(f" 好評(píng)率:{product['comment']['positive_ratio']}%") print(f" 熱門(mén)標(biāo)簽:{[t['name'] for t in product['comment']['hot_tags'][:3]]}") except Exception as e: print(f"執(zhí)行出錯(cuò):{str(e)}")
審核編輯 黃宇
-
接口
+關(guān)注
關(guān)注
33文章
9595瀏覽量
157600 -
API
+關(guān)注
關(guān)注
2文章
2472瀏覽量
66998
發(fā)布評(píng)論請(qǐng)先 登錄
京東商品評(píng)論 API 開(kāi)發(fā)指南(避坑 + 實(shí)戰(zhàn))
1688 商品詳情 API 調(diào)用與數(shù)據(jù)解析 Python 實(shí)戰(zhàn)
京東商品詳情 ID(即 SKU ID)獲取商品詳細(xì)信息參數(shù)
淘寶商品詳情API接口技術(shù)解析與實(shí)戰(zhàn)應(yīng)用
當(dāng)當(dāng)接口開(kāi)發(fā)避坑指南:3 大痛點(diǎn) + 簽名模板,0 失敗接入商品詳情接口
深度拆解京東評(píng)論接口:從多維度分析到商業(yè)價(jià)值落地的技術(shù)方案
別踩分頁(yè)坑!京東商品詳情接口實(shí)戰(zhàn)指南:從并發(fā)優(yōu)化到數(shù)據(jù)完整性閉環(huán)
別再卡分頁(yè)!淘寶全量商品接口實(shí)戰(zhàn)開(kāi)發(fā)指南:從并發(fā)優(yōu)化到數(shù)據(jù)完整性閉環(huán)
小紅書(shū)筆記詳情 API 實(shí)戰(zhàn)指南:從開(kāi)發(fā)對(duì)接、場(chǎng)景落地到收益挖掘(附避坑技巧)
京東商品詳情接口實(shí)戰(zhàn)解析:從調(diào)用優(yōu)化到商業(yè)價(jià)值挖掘(附避坑代碼)
評(píng)論