淘宝/天猫商品描述API(taobao.item_get_desc)返回值详解

淘宝/天猫的商品描述API(taobao.item_get_desc)允许开发者获取指定商品的详细描述信息。这对于需要进行商品数据分析、构建商品详情页面或进行其他与商品相关的应用开发非常有用。下面,我们将详细解析这个API的返回值。

一、API概述

taobao.item_get_desc API是淘宝/天猫开放平台提供的一个接口,通过传入商品的ID或URL,可以获取该商品的详细描述内容。这些描述通常包括商品的文字描述、图片、规格参数等。

taobao.item_get_desc

公共参数

二、请求参数

在调用taobao.item_get_desc API时,需要传递一些必要的请求参数,如:

  • item_id:商品的ID,用于唯一标识一个商品。
  • num_iid:商品的数字ID,与item_id功能类似,但格式不同。
  • fields:可选参数,用于指定需要返回的字段列表,以减小返回数据包的大小和提高处理效率。

返回数据示例


 		"item": {
		"desc": "\n  <img src=\"http://img.alicdn.com/imgextra/i3/2200639983103/O1CN01B8rO8q1YnDpqtaSHZ_!!2200639983103-1-scmitem6000.gif\" usemap=\"#IUSGU\" />\n  <map name=\"IUSGU\"><area shape=\"rect\" coords=\"6,10,786,541\" href=\"https://pages.tmall.com/wow/an/cs/act/wupr?wh_biz=tm&amp;wh_pid=3320144%2F17c73fe7b21&amp;disableNav=YES&amp;brandId=3320144&amp;chaoshi_brand_waitou=true\"></area><area shape=\"rect\" coords=\"9,561,169,731\" href=\"https://pages.tmall.com/wow/ark-pub/common/ee30c50a/tpl?wh_sid=a4a7a974fcf99970&amp;mcBrandCard=true\"></area><area shape=\"rect\" coords=\"211,561,371,721\" href=\"https://pages.tmall.com/wow/ark-pub/common/ee30c50a/tpl?wh_sid=b1f371c6cada937b&amp;mcBrandCard=true\"></area><area shape=\"rect\" coords=\"415,562,575,722\" href=\"https://pages.tmall.com/wow/ark-pub/common/ee30c50a/tpl?wh_sid=8fff1d96108c25a3&amp;mcBrandCard=true\"></area><area shape=\"rect\" coords=\"597,563,757,723\" href=\"https://pages.tmall.com/wow/ark-pub/common/ee30c50a/tpl?wh_sid=a4d5dbb8fee520eb&amp;mcBrandCard=true\"></area></map> \n  <img src=\"http://img.alicdn.com/imgextra/i3/2200639983103/O1CN01MdspcQ1YnDpofKaYI_!!2200639983103-1-scmitem6000.gif\" usemap=\"#EMBND\" />\n  <map name=\"EMBND\"><area shape=\"rect\" coords=\"3,253,355,792\" href=\"https://chaoshi.detail.tmall.com/item.htm?id=627358747270&amp;skuId=4958439969412\"></area></map> \n  <p>&nbsp;</p> \n  <p>&nbsp;</p> \n  <p>&nbsp;</p> \n  <p>&nbsp;</p> \n  <p>&nbsp;</p> \n  <p>&nbsp;</p> \n  <p>&nbsp;<img src=\"http://img.alicdn.com/imgextra/i4/2200639983103/O1CN01K5mRzF1YnDhfbLqYO_!!2200639983103-0-scmitem6000.jpg\" align=\"absmiddle\" /></p> \n  <p>&nbsp;</p> \n  <p><map name=\"GPSIJ\"><area shape=\"rect\" coords=\"194,8,374,148\" href=\"https://chaoshi.detail.tmall.com/item.htm?spm=a1z34w.13877023.0.0.626531a5VcC2US&amp;id=536597702698\"></area><area shape=\"rect\" coords=\"377,10,557,148\" href=\"https://chaoshi.detail.tmall.com/item.htm?spm=a1z34w.13877023.0.0.626531a5VcC2US&amp;id=611943282371\"></area><area shape=\"rect\" coords=\"564,15,742,150\" href=\"https://chaoshi.detail.tmall.com/item.htm?spm=a1z34w.13877023.0.0.626531a5VcC2US&amp;id=613199006000\"></area><area shape=\"rect\" coords=\"197,165,372,299\" href=\"https://chaoshi.detail.tmall.com/item.htm?spm=a1z34w.13877023.0.0.626531a5VcC2US&amp;id=602723508607\"></area><area shape=\"rect\" coords=\"382,170,554,305\" href=\"https://chaoshi.detail.tmall.com/item.htm?spm=a1z34w.13877023.0.0.626531a5VcC2US&amp;id=44107699067\"></area><area shape=\"rect\" coords=\"567,165,739,305\" href=\"https://chaoshi.detail.tmall.com/item.htm?spm=a1z34w.13877023.0.0.626531a5VcC2US&amp;id=44187888589\"></area><area shape=\"rect\" coords=\"197,318,374,455\" href=\"https://chaoshi.detail.tmall.com/item.htm?spm=a1z34w.13877023.0.0.626531a5VcC2US&amp;id=533938505960\"></area><area shape=\"rect\" coords=\"386,318,558,453\" href=\"https://chaoshi.detail.tmall.com/item.htm?spm=a1z34w.13877023.0.0.626531a5VcC2US&amp;id=591828039537\"></area><area shape=\"rect\" coords=\"567,318,741,460\" href=\"https://chaoshi.detail.tmall.com/item.htm?spm=a1z34w.13877023.0.0.626531a5VcC2US&amp;id=566408329269\"></area><area shape=\"rect\" coords=\"196,470,371,606\" href=\"https://chaoshi.detail.tmall.com/item.htm?spm=a1z34w.13877023.0.0.626531a5VcC2US&amp;id=533971548851\"></area><area shape=\"rect\" coords=\"380,473,557,610\" href=\"https://chaoshi.detail.tmall.com/item.htm?spm=a1z34w.13877023.0.0.626531a5VcC2US&amp;id=577183292025\"></area><area shape=\"rect\" coords=\"565,470,740,613\" href=\"https://chaoshi.detail.tmall.com/item.htm?spm=a1z34w.13877023.0.0.626531a5VcC2US&amp;id=573075979265\"></area><area shape=\"rect\" coords=\"197,622,262,676\" href=\"\"></area><area shape=\"rect\" coords=\"199,624,374,758\" href=\"https://chaoshi.detail.tmall.com/item.htm?spm=a1z34w.13877023.0.0.626531a5VcC2US&amp;id=554419816039\"></area><area shape=\"rect\" coords=\"381,620,556,762\" href=\"https://chaoshi.detail.tmall.com/item.htm?spm=a1z34w.13877023.0.0.626531a5VcC2US&amp;id=592956242653\"></area><area shape=\"rect\" coords=\"564,623,739,764\" href=\"https://chaoshi.detail.tmall.com/item.htm?spm=a1z34w.13877023.0.0.626531a5VcC2US&amp;id=604301910718\"></area></map> </p> \n  <p><a href=\"https://chaoshi.detail.tmall.com/item.htm?spm=a220o.7406545.0.0.32c7697bmJA9L1&amp;id=590048908797\" target=\"_blank\"></a></p> \n  <p><img src=\"http://img.alicdn.com/imgextra/i3/2200639983103/O1CN01UzEW4I1YnDhVdkEFJ_!!2200639983103-0-scmitem6000.jpg\" align=\"absmiddle\" /></p> \n  <p>&nbsp;</p> \n  <p><img src=\"http://img.alicdn.com/imgextra/i3/2200639983103/O1CN016eKqLt1YnDnXbDcWs_!!2200639983103-0-scmitem6000.jpg\" align=\"absmiddle\" /><img src=\"http://img.alicdn.com/imgextra/i2/2200639983103/O1CN01GDW3H61YnDnhPYxl7_!!2200639983103-0-scmitem6000.jpg\" align=\"absmiddle\" /><img align=\"absmiddle\" src=\"http://img.alicdn.com/imgextra/i2/3596645218/O1CN01seMU6n1oPt9fOvcj4_!!3596645218-0-scmitem6000.jpg\" /><img src=\"http://img.alicdn.com/imgextra/i2/2200639983103/O1CN0162Bmh21YnDnaPMaTM_!!2200639983103-0-scmitem6000.jpg\" align=\"absmiddle\" /><img align=\"absmiddle\" src=\"http://img.alicdn.com/imgextra/i3/3596645218/O1CN01f4fzGM1oPt9XJ7Hk2_!!3596645218-0-scmitem6000.jpg\" /><img align=\"absmiddle\" src=\"http://img.alicdn.com/imgextra/i4/3596645218/O1CN01rWjGD61oPt9fgZiT4_!!3596645218-0-scmitem6000.jpg\" /><img src=\"http://img.alicdn.com/imgextra/i2/2200639983103/O1CN01DfHuV61YnDjRoGnAQ_!!2200639983103-0-scmitem6000.jpg\" align=\"absmiddle\" /><img src=\"http://img.alicdn.com/imgextra/i3/2200639983103/O1CN01QZgCx01YnDjXm4Y03_!!2200639983103-0-scmitem6000.jpg\" align=\"absmiddle\" /><img align=\"absmiddle\" src=\"http://img.alicdn.com/imgextra/i3/2142811280/O1CN01WxEC6x1LKHSoigkL0_!!2142811280-0-scmitem6000.jpg\" /><img align=\"absmiddle\" src=\"http://img.alicdn.com/imgextra/i2/2200639983103/O1CN01CzM2ro1YnDUFRy4lH_!!2200639983103-0-scmitem6000.jpg\" /><img src=\"http://img.alicdn.com/imgextra/i3/2200639983103/O1CN01hy4eW41YnDnoTFBOb_!!2200639983103-0-scmitem6000.jpg\" align=\"absmiddle\" /></p> &nbsp; \n  <p>&nbsp;</p> \n  <p>&nbsp;</p>\n  <script src=\"https://g.alicdn.com/i/popshop/0.0.23/p/seemore/load.js?c\"></script> \n ",
		"data_from": "app_vip"
	},
	"error": "",
	"reason": "",
	"error_code": "0000",
	"cache": 0,
	"api_info": "today:24 max:10000 all[39=24+0+15];expires:2030-12-31",
	"execution_time": "0.666",
	"server_time": "Beijing/2023-06-21 09:18:44",
	"client_ip": "115.153.49.96",
	"call_args": [],
	"api_type": "taobao",
	"translate_language": "zh-CN",
	"translate_engine": "baidu",
	"server_memory": "0.86MB",
	"request_id": "gw-4.64924ff43c9b9",
	"last_id": "1821985889"

三、返回值详解

当请求成功后,taobao.item_get_desc API将返回一个JSON格式的数据包,其中包含以下关键字段:

  1. request_id
    • 类型:字符串
    • 描述:请求的唯一标识符,用于跟踪和排查问题。
  2. item
    • 类型:JSON对象

    • 描述:包含商品的详细信息。具体字段可能因请求参数的不同而有所差异,但通常包括以下几个部分:

      a. title

      • 类型:字符串
      • 描述:商品的标题。

      b. desc

      • 类型:字符串
      • 描述:商品的详细描述内容,通常包括文字描述和HTML格式的排版信息。开发者可以根据需要对这部分内容进行解析和展示。

      c. desc_modules

      • 类型:数组

      • 描述:商品的描述模块列表。每个模块可能包含不同的内容类型(如文字、图片、视频等),并以特定的结构进行组织。开发者可以根据需要遍历这个数组,并分别处理每个模块的内容。

      • 子字段示例:

        • type:模块类型(如文字、图片等)
        • content:模块内容(根据类型不同,可能是文本、图片链接等)

      d. other_fields

      • 类型:JSON对象
      • 描述:根据请求参数fields指定的其他字段的返回值。这些字段可能包括商品的图片、价格、规格参数等。具体字段和返回格式将根据实际请求而有所不同。
  3. error_code
    • 类型:整数
    • 描述:如果请求失败,将返回错误代码。开发者可以根据这个代码查找相应的错误原因和解决方案。
  4. error_msg
    • 类型:字符串
    • 描述:如果请求失败,将返回错误消息。这个消息将提供更详细的错误原因和可能的解决方案。
/home/lion/h618/h618-android12.0/longan/kernel/linux-5.4/drivers/hid/uart-hid/uart_over_hid.c:94:10: error: redefinition of 'hid_type' enum hid_type { MOUSE, KEYBOARD } type; // 设备类型 ^ /home/lion/h618/h618-android12.0/longan/kernel/linux-5.4/include/linux/hid.h:533:6: note: previous definition is here enum hid_type { ^ /home/lion/h618/h618-android12.0/longan/kernel/linux-5.4/drivers/hid/uart-hid/uart_over_hid.c:134:18: warning: GCC does not allow variable declarations in for loop initializers before C99 [-Wgcc-compat] for (int j = 0; j < udata->expect_len - 1; j++) { ^ /home/lion/h618/h618-android12.0/longan/kernel/linux-5.4/drivers/hid/uart-hid/uart_over_hid.c:144:79: error: too few arguments to function call, expected 5, have 4 hid_input_report(udata->hdev, report, udata->expect_len - 3, 0); ~~~~~~~~~~~~~~~~ ^ /home/lion/h618/h618-android12.0/longan/kernel/linux-5.4/include/linux/hid.h:886:5: note: 'hid_input_report' declared here int hid_input_report(struct hid_device *, int type, u8 *, u32, int); ^ /home/lion/h618/h618-android12.0/longan/kernel/linux-5.4/drivers/hid/uart-hid/uart_over_hid.c:157:20: error: incompatible function pointer types initializing 'void (*)(struct tty_struct *, const unsigned char *, char *, int)' with an expression of type 'void (struct tty_struct *, const u8 *, const u8 *, int)' (aka 'void (struct tty_struct *, const unsigned char *, const unsigned char *, int)') [-Werror,-Wincompatible-function-pointer-types] .receive_buf = uart_receive, ^~~~~~~~~~~~ /home/lion/h618/h618-android12.0/longan/kernel/linux-5.4/drivers/hid/uart-hid/uart_over_hid.c:232:9: warning: ISO C90 forbids mixing declarations and code [-Wdeclaration-after-statement] int ret = hid_add_device(hdev); ^ 2 warnings and 3
最新发布
11-06
def main(): if args.output_path is not None and os.path.exists(args.output_path): # print(f"Results {args.output_path} already generated. Exit.") print(f"Results {args.output_path} already generated. Overwrite.") # exit() # a hack here to auto set model group if args.smooth_scale and args.vila_20: if os.path.exists(args.act_scale_path): print(f"Found existing Smooth Scales {args.act_scale_path}, skip.") else: from awq.quantize import get_smooth_scale act_scale = get_smooth_scale(args.model_path, args.media_path) os.makedirs(os.path.dirname(args.act_scale_path), exist_ok=True) torch.save(act_scale, args.act_scale_path) print("Save act scales at " + str(args.act_scale_path)) args.model_path = args.model_path + "/llm" if args.dump_awq is None and args.dump_quant is None: exit() if args.dump_awq and os.path.exists(args.dump_awq): print(f"Found existing AWQ results {args.dump_awq}, exit.") exit() model, enc = build_model_and_enc(args.model_path, args.dtype) if args.tasks is not None: # https://github.com/IST-DASLab/gptq/blob/2d65066eeb06a5c9ff5184d8cebdf33662c67faf/llama.py#L206 if args.tasks == "wikitext": testenc = load_dataset("wikitext", "wikitext-2-raw-v1", split="test") testenc = enc("\n\n".join(testenc["text"]), return_tensors="pt") model.seqlen = 2048 testenc = testenc.input_ids.to(model.device) nsamples = testenc.numel() // model.seqlen model = model.eval() nlls = [] for i in tqdm.tqdm(range(nsamples), desc="evaluating..."): batch = testenc[:, (i * model.seqlen) : ((i + 1) * model.seqlen)].to( model.device ) with torch.no_grad(): lm_logits = model(batch).logits shift_logits = lm_logits[:, :-1, :].contiguous().float() shift_labels = testenc[ :, (i * model.seqlen) : ((i + 1) * model.seqlen) ][:, 1:] loss_fct = nn.CrossEntropyLoss() loss = loss_fct( shift_logits.view(-1, shift_logits.size(-1)), shift_labels.view(-1) ) neg_log_likelihood = loss.float() * model.seqlen nlls.append(neg_log_likelihood) ppl = torch.exp(torch.stack(nlls).sum() / (nsamples * model.seqlen)) print(ppl.item()) results = {"ppl": ppl.item()} if args.output_path is not None: os.makedirs(os.path.dirname(args.output_path), exist_ok=True) with open(args.output_path, "w") as f: json.dump(results, f, indent=2) else: task_names = args.tasks.split(",") lm_eval_model = LMEvalAdaptor(args.model_path, model, enc, args.batch_size) results = evaluator.simple_evaluate( model=lm_eval_model, tasks=task_names, batch_size=args.batch_size, no_cache=True, num_fewshot=args.num_fewshot, ) print(evaluator.make_table(results)) if args.output_path is not None: os.makedirs(os.path.dirname(args.output_path), exist_ok=True) # otherwise cannot save results["config"]["model"] = args.model_path with open(args.output_path, "w") as f: json.dump(results, f, indent=2)这个函数也帮我详细解释一下嘛
07-26
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值