当前位置: 首页 > article >正文

虾皮(Shopee)商品ID获取商品详情请求示例

通过万邦(或任何第三方工具/平台)使用虾皮(Shopee)商品ID获取商品详情,需要明确以下几点:


核心思路

  1. -可调用Shopee的 item_get 接口。

    • 需要 API Key、Shop ID、Item ID 等参数,并生成签名(签名算法需按Shopee要求实现)。
  2. 请求示例

# coding:utf-8
"""
Compatible for python2.x and python3.x
requirement: pip install requests
"""
from __future__ import print_function
import requests
# 请求示例 url 默认请求参数已经做URL编码
# 封装好的虾皮商品详情供应商demo url=o0b.cn/ibrad,复制链接获取测试
url = "https://api-gw.onebound.cn/shopee/item_get/?key=<[您自己的apiKey](https://o0b.cn/ibrad)>&secret=<您自己的apiSecret>&num_iid=958470529/21785867874&country=.co.th"
headers = {
    "Accept-Encoding": "gzip",
    "Connection": "close"
}
if __name__ == "__main__":
    r = requests.get(url, headers=headers)
    json_obj = r.json()
    print(json_obj)

具体步骤(响应示例)

1. 获取商品页面数据

请求参数:num_iid=958470529/21785867874&country=.co.th 。提取页面内嵌的JSON数据。

{
  "items": {
    "totalpage": 31,
    "total_results": 182,
    "page_size": 6,
    "page": "1",
    "item": [
      {
        "rate_content": "Just ok. Delivery time as expected. If you're 155cm and below, this dress length will be at your calf. Size is accurate, do follow your exact measurement. Material is acceptable. ",
        "rate_date": "2020-08-27 07:48:16",
        "pics": [],
        "display_user_nick": "t*****y",
        "auction_sku": "White,M",
        "liked_count": 0,
        "video": null
      },
      {
        "rate_content": "The quality suits the price. \nFor hijabi it best to wear camisole along as it quite see through. \nPackaging is nice 👍🏽 \nReceived less than 10 days💯\n",
        "rate_date": "2020-09-08 02:58:25",
        "pics": [
          "https://cf.shopee.com.my/file/651f130eceda11f9a6e4f4b6e077ef6d",
          "https://cf.shopee.com.my/file/fc41803a377916bc2e7293cdb04e22c4"
        ],
        "display_user_nick": "eikasaleh12",
        "auction_sku": "White,M",
        "liked_count": 13,
        "video": "https://down-aka-sg.vod.susercontent.com/api/v4/11110103/mms/my_52b44f3f-9fd1-49fc-93d2-bf9a8e6d73f1_000038.default.mp4"
      },
      {
        "rate_content": "Bought on 27-8 received on 5-9. Fast delivery seller so responsive and considerate (can make offer). The dress is also true to the size chart only 1-3 cm difference so better measure first.Im 150 cm 49kg and bought size L quite regret bcs quite big on me so should measure first bcs dress not small",
        "rate_date": "2020-09-05 11:59:01",
        "pics": [
          "https://cf.shopee.com.my/file/cdfb9576b813fc03cc21641d7f527812",
          "https://cf.shopee.com.my/file/f2590e258d9b758944791dc653af8a5a",
          "https://cf.shopee.com.my/file/c53b401b8a8acc6a75ed12c55121d4a9"
        ],
        "display_user_nick": "s*****2",
        "auction_sku": "White,L",
        "liked_count": 0,
        "video": null
      },
      {
        "rate_content": "Super fast deliveryyyyyyyy!!!! The dress is so cute! So worth it with the price. Thank you seller✨✨✨✨✨✨✨✨✨",
        "rate_date": "2020-06-30 09:33:28",
        "pics": [
          "https://cf.shopee.com.my/file/55cf1a31ea3f6112758d0305a1431aa3"
        ],
        "display_user_nick": "s*****d",
        "auction_sku": "White,M",
        "liked_count": 17,
        "video": null
      },
      {
        "rate_content": "Received in good condition. Quite a nice dress, no lining inside. Quality ok for the price.",
        "rate_date": "2020-08-30 03:31:24",
        "pics": [
          "https://cf.shopee.com.my/file/d6cc92d51971c141d35c652d6630f316"
        ],
        "display_user_nick": "c*****o",
        "auction_sku": "White,M",
        "liked_count": 0,
        "video": "https://down-aka-sg.vod.susercontent.com/api/v4/11110103/mms/my_e32b2cd7-e803-4ff2-a9f6-a0f677a3378b_000039.default.mp4"
      },
      {
        "rate_content": "Berat 70++ tggi 155cm muat pakai saiz 2xl ni. Kain cntik xjarang.",
        "rate_date": "2020-09-09 07:52:41",
        "pics": [
          "https://cf.shopee.com.my/file/20423407da83eac240baa28228baf38c"
        ],
        "display_user_nick": "hmm007",
        "auction_sku": "White,2XL",
        "liked_count": 0,
        "video": null
      }
    ]
  },
  "secache": "c20d295a2be98ac77549ddc539c6ae4a",
  "secache_time": 1729758525,
  "secache_date": "2024-10-24 16:28:45",
  "translate_status": "",
  "translate_time": 0,
  "language": {
    "default_lang": "cn",
    "current_lang": "cn"
  },
  "error": "",
  "reason": "",
  "error_code": "0000",
  "cache": 0,
  "api_info": "today:44 max:10000 all[2890=44+12+2834];expires:2030-10-30",
  "execution_time": "2.048",
  "server_time": "Beijing/2024-10-24 16:28:45",
  "client_ip": "220.177.180.75",
  "call_args": {
    "num_iid": "239487269/5435412264",
    "data": ".com.my",
    "page": "1"
  },
  "api_type": "shopee",
  "translate_language": "zh-CN",
  "translate_engine": "",
  "server_memory": "3.18MB",
  "request_id": "gw-3.671a053b79091",
  "last_id": "3638202001"
}
2. 解析关键字段

从返回的JSON数据中提取核心信息:

{
  "item_id": "商品ID",
  "name": "商品名称",
  "price": 价格(单位为分,需除以100000,
  "description": "商品描述",
  "images": ["图片URL列表"],
  "stock": 库存,
  "shop_info": {
    "shop_id": "店铺ID",
    "shop_name": "店铺名称"
  }
}

注意事项

  1. 异常示例
{
  "error": "item-not-found",
  "reason": "商品没找到",
  "error_code": "2000",
  "success": 0,
  "cache": 0,
  "api_info": "today:0 max:10000",
  "execution_time": 0.081,
  "server_time": "Beijing/2020-06-10 23:44:00",
  "call_args": [],
  "api_type": "shopee",
  "request_id": "1ee0ffc041242"}
  1. 动态渲染问题
    • 如果数据通过AJAX加载,需使用 SeleniumPlaywright 模拟浏览器操作:
      from selenium import webdriver
      from selenium.webdriver.chrome.options import Options
      
      def get_dynamic_page(url):
          options = Options()
          options.headless = True
          driver = webdriver.Chrome(options=options)
          driver.get(url)
          html = driver.page_source
          driver.quit()
          return html
      

如需进一步优化或解决具体问题(如大规模采集),请留言或私聊!


http://www.kler.cn/a/598487.html

相关文章:

  • Android Compose 约束布局(ConstraintLayout、Modifier.constrainAs)源码深度剖析(十二)
  • 【完整版】DeepSeek-R1大模型学习笔记(架构、训练、Infra、复现代码)
  • SQL的DCL,DDL,DML和DQL分别是什么
  • 2025-03-21 Unity 序列化 —— 自定义2进制序列化
  • 面试常问系列(一)-神经网络参数初始化
  • NLP高频面试题(十一)——RLHF的流程有哪些
  • ModuleNotFoundError: No module named ‘flask‘ 错误
  • 堆的相关要点以及模拟实现
  • 《可爱风格 2048 游戏项目:HTML 实现全解析》
  • 前后端开发概述:架构、技术栈与未来趋势
  • Linux系统移植篇(十)根文件系统构建 V3 - Yocto
  • 第8章:Docker数据持久化与卷管理
  • 基于Matlab的大气湍流光束传输特性的研究
  • Android Compose 层叠布局(ZStack、Surface)源码深度剖析(十三)
  • Android 根据Url使用Retrofit框架进行文件下载
  • 从复杂到集成:APVSG系列多通道相参矢量信号源重塑量子比特(Qubit )信号生成技术
  • qt 对QObject::tr()函数进行重定向
  • Haption Virtuose力反馈设备在CAVE投影系统中提供真实训练交互
  • 基于虚拟知识图谱的语义化决策引擎
  • 机器人前沿技术的发展与展望