首页 > 大数据 > 数据分析 > 京东商品属性API数据解析:颜色、尺寸与材质
jingdong.ware.get 或
jd.item.detail.get,通过商品ID(wareId/sku_id)获取完整属性。jingdong.ware.search,通过关键词获取商品列表及基础属性。wareId=100060000001)、字段列表(如
field=title,price,attributes)。https://api.jd.com/routerjson?method=jingdong.ware.get&app_key=XXX&wareId=100060000001...wareInfo或
sku_info中。attributes数组或
sku_info的
attributes字段。json"attributes": [{"name": "颜色", "values": ["红色", "蓝色", "白色"]}]或
json"sku_info": [{"sku_id": "100012345678", "attributes": "颜色:红色;尺寸:M", "price": "299.00"}]attributes中。json"attributes": [{"name": "尺寸", "values": ["S", "M", "L", "XL"]}]attributes或商品描述字段(如
desc)。json"attributes": [{"name": "材质", "values": ["棉95%", "涤纶5%"]}]pythonimport requestsimport hashlibimport jsonclass JDAPI:def __init__(self, app_key, app_secret):self.app_key = app_keyself.app_secret = app_secretself.api_url = "https://api.jd.com/routerjson"def generate_sign(self, params):sorted_params = sorted(params.items(), key=lambda x: x[0])sign_str = self.app_secret + ''.join([f"{k}{v}" for k, v in sorted_params]) + self.app_secretreturn hashlib.md5(sign_str.encode('utf-8')).hexdigest().upper()def get_item_detail(self, ware_id):params = {"method": "jingdong.ware.get","app_key": self.app_key,"timestamp": time.strftime("%Y-%m-%d %H:%M:%S"),"format": "json","v": "2.0","wareId": ware_id,"field": "title,price,attributes"}params["sign"] = self.generate_sign(params)response = requests.get(self.api_url, params=params)return response.json()# 使用示例if __name__ == "__main__":app_key = "YOUR_APP_KEY"app_secret = "YOUR_APP_SECRET"ware_id = "100060000001"jd_api = JDAPI(app_key, app_secret)item_data = jd_api.get_item_detail(ware_id)# 解析颜色、尺寸、材质if "wareInfo" in item_data:attributes = item_data["wareInfo"].get("attributes", [])for attr in attributes:if attr["name"] == "颜色":colors = attr.get("values", [])elif attr["name"] == "尺寸":sizes = attr.get("values", [])elif attr["name"] == "材质":materials = attr.get("values", [])print(f"颜色: {colors}, 尺寸: {sizes}, 材质: {materials}")
sku_info数组获取各规格属性。通过以上流程,可高效获取并解析京东商品的颜色、尺寸和材质属性,适用于电商数据分析、竞品监控等场景。建议定期查阅京东开放平台最新文档,确保接口调用符合规范。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/70046834/viewspace-3095098/ ,如需转载,请注明出处,否则将追究法律责任。