> For the complete documentation index, see [llms.txt](https://developers.oxylabs.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.oxylabs.io/api-targets/cn/sou-suo-yin-qing/google/shopping/shopping-product.md).

# 购物商品

该 `google_shopping_product` source 会从 Google Shopping 检索详细商品信息（标题、描述、定价、卖家、相关商品、评论等），使用一个 **商品 token** 获取自 `google_shopping_search` ([此处](/api-targets/cn/sou-suo-yin-qing/google/shopping/shopping-search.md)) 或 `google_search`.

## **请求示例**

在下面的代码示例中，我们使用有效 token 发起请求，以获取 Google Shopping 商品页面。

{% tabs %}
{% tab title="cURL" %}

```shell
curl 'https://realtime.oxylabs.io/v1/queries' \
--user 'USERNAME:PASSWORD' \
-H 'Content-Type: application/json' \
-d '{
       "source": "google_shopping_product",
       "query": "<PRODUCT_TOKEN>",
       "render": "html",
       "parse": true
    }'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
from pprint import pprint


# Structure payload.
payload = {
    "source": "google_shopping_product",
    "query": "[product_token_string]",
    "render": "html",
    "parse": True
}

# Get response.
response = requests.request(
    'POST',
    'https://realtime.oxylabs.io/v1/queries',
    auth=('USERNAME', 'PASSWORD'),
    json=payload,
)

# Print prettified response to stdout.
pprint(response.json())
```

{% endtab %}

{% tab title="Node.js" %}

```javascript
const https = require("https");

const username = "USERNAME";
const password = "PASSWORD";
const body = {
    source: "google_shopping_product",
    query: "[product_token_string]",
    render: "html",
    parse: true
};

const options = {
    hostname: "realtime.oxylabs.io",
    path: "/v1/queries",
    method: "POST",
    headers: {
        "Content-Type": "application/json",
        Authorization:
            "Basic " + Buffer.from(`${username}:${password}`).toString("base64"),
    },
};

const request = https.request(options, (response) => {
    let data = "";

    response.on("data", (chunk) => {
        data += chunk;
    });

    response.on("end", () => {
        const responseData = JSON.parse(data);
        console.log(JSON.stringify(responseData, null, 2));
    });
});

request.on("error", (error) => {
    console.error("Error:", error);
});

request.write(JSON.stringify(body));
request.end();
```

{% endtab %}

{% tab title="HTTP" %}

```http
https://realtime.oxylabs.io/v1/queries?source=google_shopping_product&query=[product_token_string]&parse=true&access_token=12345abcde
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$params = array(
    'source' => 'google_shopping_product',
    'query' => '[product_token_string]',
    'render' => 'html',
    'parse' => true
);

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "https://realtime.oxylabs.io/v1/queries");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERPWD, "USERNAME" . ":" . "PASSWORD");

$headers = array();
$headers[] = "Content-Type: application/json";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
echo $result;

if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close($ch);
```

{% endtab %}

{% tab title="Golang" %}

```go
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io/ioutil"
	"net/http"
)

func main() {
	const Username = "USERNAME"
	const Password = "PASSWORD"

	payload := map[string]interface{}{
		"source": "google_shopping_product",
		"query": "[product_token_string]",
		"render": "html",
		"parse": true,
	}

	jsonValue, _ := json.Marshal(payload)

	client := &http.Client{}
	request, _ := http.NewRequest("POST",
		"https://realtime.oxylabs.io/v1/queries",
		bytes.NewBuffer(jsonValue),
	)

	request.SetBasicAuth(Username, Password)
	response, _ := client.Do(request)

	responseText, _ := ioutil.ReadAll(response.Body)
	fmt.Println(string(responseText))
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Json;
using System.Threading.Tasks;

namespace OxyApi
{
    class Program
    {
        static async Task Main()
        {
            const string Username = "USERNAME";
            const string Password = "PASSWORD";

            var parameters = new {
                source = "google_shopping_product",
                query = "[product_token_string]",
                render = "html",
                parse = true
            };

            var client = new HttpClient();

            Uri baseUri = new Uri("https://realtime.oxylabs.io");
            client.BaseAddress = baseUri;

            var requestMessage = new HttpRequestMessage(HttpMethod.Post, "/v1/queries");
            requestMessage.Content = JsonContent.Create(parameters);

            var authenticationString = $"{Username}:{Password}";
            var base64EncodedAuthenticationString = Convert.ToBase64String(System.Text.ASCIIEncoding.UTF8.GetBytes(authenticationString));
            requestMessage.Headers.Add("Authorization", "Basic " + base64EncodedAuthenticationString);

            var response = await client.SendAsync(requestMessage);
            var contents = await response.Content.ReadAsStringAsync();

            Console.WriteLine(contents);
        }
    }
}
```

{% endtab %}

{% tab title="Java" %}

```java
package org.example;

import okhttp3.*;
import org.json.JSONObject;
import java.util.concurrent.TimeUnit;

public class Main implements Runnable {
    private static final String AUTHORIZATION_HEADER = "Authorization";
    public static final String USERNAME = "USERNAME";
    public static final String PASSWORD = "PASSWORD";

    public void run() {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("source", "google_shopping_product");
        jsonObject.put("query", "[product_token_string]");
        jsonObject.put("render", "html");
        jsonObject.put("parse", true);

        Authenticator authenticator = (route, response) => {
            String credential = Credentials.basic(USERNAME, PASSWORD);
            return response
                    .request()
                    .newBuilder()
                    .header(AUTHORIZATION_HEADER, credential)
                    .build();
        };

        var client = new OkHttpClient.Builder()
                .authenticator(authenticator)
                .readTimeout(180, TimeUnit.SECONDS)
                .build();

        var mediaType = MediaType.parse("application/json; charset=utf-8");
        var body = RequestBody.create(jsonObject.toString(), mediaType);
        var request = new Request.Builder()
                .url("https://realtime.oxylabs.io/v1/queries")
                .post(body)
                .build();

        try (var response = client.newCall(request).execute()) {
            if (response.body() != null) {
                try (var responseBody = response.body()) {
                    System.out.println(responseBody.string());
                }
            }
        } catch (Exception exception) {
            System.out.println("Error: " + exception.getMessage());
        }

        System.exit(0);
    }

    public static void main(String[] args) {
        new Thread(new Main()).start();
    }
}
```

{% endtab %}

{% tab title="JSON" %}

```json
{
    "source": "google_shopping_product",
    "query": "[product_token_string]",
    "render": "html",
    "parse": true
}
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
**重要：** 该 `query` 参数必须包含一个由 `google_shopping_search` [source 生成的](/api-targets/cn/sou-suo-yin-qing/google/shopping/shopping-search.md).
{% endhint %}

我们在示例中使用同步 [**Realtime**](/products/cn/web-scraper-api/integration-methods/realtime.md) 集成方法。如果您想使用 [**Proxy Endpoint**](/products/cn/web-scraper-api/integration-methods/proxy-endpoint.md) 或异步 [**Push-Pull**](/products/cn/web-scraper-api/integration-methods/push-pull.md) 集成，请参阅 [**集成方法**](/products/cn/web-scraper-api/integration-methods.md) 部分。

## 请求参数值

### 通用

用于抓取 Google Shopping 商品页面的基本设置和自定义选项。

<table><thead><tr><th width="222">参数</th><th width="330.3333333333333">描述</th><th>默认值</th></tr></thead><tbody><tr><td><mark style="background-color:green;"><strong><code>source 生成的</code></strong></mark></td><td>设置爬虫。</td><td><code>google_shopping_product</code></td></tr><tr><td><mark style="color:默认;background-color:green;"><strong><code>query</code></strong></mark></td><td>商品 token 来源于 <code>google_shopping_search</code> 或 <code>google_search</code></td><td>-</td></tr><tr><td><code>render</code></td><td>当设置为 <code>html</code>. <strong>必需</strong> 以从“More stores”部分获取额外定价结果。 <a href="/spaces/ZwEHB9k4MH4pDy80n9mF/pages/9d7133837001de31de5dfd0796cfbc6fdd7c78c8#javascript-rendering"><strong>更多信息</strong></a><strong>.</strong></td><td>-</td></tr><tr><td><code>parse</code></td><td>当设置为 <code>true</code>。查看输出 <a href="#output-data-dictionary"><strong>数据字典</strong></a>.</td><td><code>false</code></td></tr><tr><td><code>callback_url</code></td><td>指向您的回调端点的 URL。 <a href="/spaces/ZwEHB9k4MH4pDy80n9mF/pages/f93fe40aed5366f8033cd2ebfae30e61c16a4f51"><strong>更多信息</strong></a></td><td>-</td></tr><tr><td><code>user_agent_type</code></td><td>设备类型和浏览器。完整列表可见 <a href="/spaces/ZwEHB9k4MH4pDy80n9mF/pages/3e6a8ee6a2915a55b276cc31a20735fe1e0e4ed1"><strong>此处</strong></a>.</td><td><code>桌面</code></td></tr></tbody></table>

&#x20;   \- 必填参数

### 本地化

将结果适配到特定地理位置、域名和语言。

{% hint style="warning" %}
**注：** 本地化参数（`gl` 和 `hl`）现已嵌入到商品 token 中。要获取 `google_shopping_products` 与原始搜索结果匹配的数据，我们建议将这些字段留空，除非确实需要覆盖。&#x20;
{% endhint %}

<table><thead><tr><th width="218">参数</th><th width="336.3333333333333">描述</th><th>默认值</th></tr></thead><tbody><tr><td><code>geo_location</code></td><td>结果应适配的地理位置。正确使用此参数对于获取正确数据极其重要。更多信息请参阅我们建议的 <code>geo_location</code> 参数结构 <a href="/spaces/ZwEHB9k4MH4pDy80n9mF/pages/8100bad86572299adc88ab0e6fd42d380eb8ca21#google"><strong>此处</strong></a><strong>.</strong></td><td>-</td></tr><tr><td><code>locale</code></td><td><code>Accept-Language</code> 用于更改界面语言的请求头值。 <a href="/spaces/ZwEHB9k4MH4pDy80n9mF/pages/b3ae8c9380989171fb2ce419480bef96ead9c1d5#locale-1"><strong>更多信息</strong></a>.</td><td>-</td></tr></tbody></table>

## 结构化数据

下面可以找到一个 **结构化输出示例** 用于 `google_shopping_product`.

{% file src="/files/46a86d9cff57c37578c228a0762c9b08a1824cb5" %}

## 输出数据字典

**HTML 示例**

<figure><img src="/files/3316be995dce2e2e0a2ca3fc6e3c3aad98ba2994" alt=""><figcaption></figcaption></figure>

#### JSON 结构

下表详细列出了我们解析的每个商品页面元素，以及其描述和数据类型。该表还包含一些元数据。

<table><thead><tr><th width="247.11328125">键</th><th width="384">描述</th><th>类型</th></tr></thead><tbody><tr><td><code>url</code></td><td>Google Shopping 商品页面的 URL。</td><td>字符串</td></tr><tr><td><code>title</code> （可选） </td><td>商品列表的标题。</td><td>字符串</td></tr><tr><td><code>description</code></td><td>商品的详细描述。</td><td>字符串</td></tr><tr><td><code>images</code></td><td>包含商品图片的对象。</td><td>对象</td></tr><tr><td><code>images.full_size</code></td><td>商品全尺寸图片 URL 数组。</td><td>数组</td></tr><tr><td><code>images.thumbnails</code></td><td>商品缩略图 URL 数组。</td><td>数组</td></tr><tr><td><code>pricing</code></td><td>包含所有线上定价信息的数组。</td><td>数组</td></tr><tr><td><code>reviews</code></td><td>包含评论信息的对象。（仅限美国）</td><td>对象</td></tr><tr><td><code>variants</code></td><td>包含商品变体（颜色、尺寸等）的对象数组。</td><td>数组</td></tr><tr><td><code>related_items</code></td><td>包含相关商品的对象数组。</td><td>数组</td></tr><tr><td><code>specifications</code></td><td>包含商品规格的对象数组。</td><td>数组</td></tr><tr><td><code>parse_status_code</code></td><td>解析任务的状态码。您可以在此查看解析器状态码说明 <a href="https://github.com/oxylabs/gitbook-public-english/blob/master/scraping-solutions/web-scraper-api/targets/google/shopping/broken-reference/README.md"><strong>此处</strong></a>.</td><td>整数</td></tr><tr><td><code>created_at</code></td><td>抓取任务创建时的时间戳。</td><td>时间戳</td></tr><tr><td><code>updated_at</code></td><td>抓取任务完成时的时间戳。</td><td>时间戳</td></tr><tr><td><code>status_code</code></td><td>抓取任务的状态码。您可以在此查看爬虫状态码说明 <a href="https://github.com/oxylabs/gitbook-public-english/blob/master/scraping-solutions/web-scraper-api/targets/google/shopping/broken-reference/README.md"><strong>此处</strong></a>.</td><td>整数</td></tr><tr><td><code>job_id</code></td><td>与该抓取任务关联的任务 ID。</td><td>字符串</td></tr></tbody></table>

{% hint style="info" %}
在以下部分中，当某种结果类型存在多个条目时，解析后的 JSON 代码片段会被缩短。
{% endhint %}

### 定价

包含商品定价信息的对象。

<figure><img src="/files/bdf21e47fc04cd241e59c1c2f3c3250d451a7410" alt=""><figcaption></figcaption></figure>

```json
...
   "pricing": {
    "online": [
        {
          "price": 559,
          "seller": "Walmart - Seller",
          "details": "Pny GeForce RTX 4070 GPU 12gb Xlr8 Gaming Verto Epic-x RGB Triple Fan Dlss 3 Graphics Card",
          "currency": "USD",
          "condition": "New",
          "seller_link": "https://www.walmart.com/ip/PNY-GeForce-RTX-4070-GPU-12GB-XLR8-Gaming-VERTO-EPIC-X-RGB-Triple-Fan-DLSS-3-Graphics-Card/1396859462?wmlspartner=wlpa&selectedSellerId=101035116&selectedOfferId=159733DADC653E1891C050148D16D747&conditionGroupCode=1",
          "price_shipping": 22.05
        },
...
    ]
},
...
```

<table><thead><tr><th width="231">键（pricing[]）</th><th width="375">描述</th><th>类型</th></tr></thead><tbody><tr><td><code>online</code></td><td>包含商品定价详情的对象数组。</td><td>数组</td></tr><tr><td><code>online.price</code></td><td>以指定货币表示的商品价格。</td><td>浮点数</td></tr><tr><td><code>online.seller</code></td><td>提供该商品的卖家或商家的名称。</td><td>字符串</td></tr><tr><td><code>online.details</code></td><td>关于商品和购买的附加详情，例如配送和退货政策。</td><td>字符串</td></tr><tr><td><code>online.currency</code></td><td>商品价格的货币代码。</td><td>字符串</td></tr><tr><td><code>online.condition</code></td><td>商品的状况。</td><td>字符串</td></tr><tr><td><code>online.price_tax</code></td><td>适用于商品价格的税额。</td><td>浮点数</td></tr><tr><td><code>online.price_total</code> （可选）</td><td>商品总价，含税。</td><td>浮点数</td></tr><tr><td><code>online.seller_link</code></td><td>商品卖家页面的 URL。</td><td>字符串</td></tr><tr><td><code>online.price_shipping</code></td><td>商品的运费。</td><td>浮点数</td></tr></tbody></table>

### 评论

包含该商品评论和评分信息的对象。

{% hint style="info" %}
目前，评论仅在美国地区可用。
{% endhint %}

<figure><img src="/files/ef4826c0878cc5b204e75afa4c6118493d47ae22" alt=""><figcaption></figcaption></figure>

```json
...       
       "reviews": {
    "rating": 4.7,
    "top_review": {
        "text": "我的电脑是 Dell Optiplex 9020，i7-4770，32MB，500GB SSD。三风扇显卡很长，而且为了装进 Optiplex 机箱，必须拆掉硬盘架。电源升级到 750 瓦，这需要一个适配器连接 Dell 主板。完成这些改装后，显卡安装过程毫无波折，但你得用 Google 才能在 Nvidia 网站上找到驱动程序。我把这块 GPU 用于 Blender 中的 3D 动画制作。我对 EEVEE 和 Cycles 中光线追踪渲染的速度非常满意。由于这是一台旧电脑，电脑的 CPU 从来不会跑到 100%，而且到目前为止我还没能把这块显卡的性能完全榨干。我听不到风扇在转，估计我还没给它上过足够高的负载。它在渲染时会有一点电子嗡嗡声。\u00a0较少",
        "author": "walmart.com 购物者",
        "rating": 5,
        "source": "在 walmart.com 上评论"
      },
      "rating_stars": 4.7,
      "reviews_count": 51,
      "reviews_by_stars": {
        "1": {
          "reviews_count": 2
        },
        "2": {
          "reviews_count": 0
        },
        "3": {
          "reviews_count": 2
        },
        "4": {
          "reviews_count": 3
        },
        "5": {
          "reviews_count": 44
        }
    },
},
...
```

<table><thead><tr><th width="253">Key(reviews[])</th><th width="375">描述</th><th>类型</th></tr></thead><tbody><tr><td><code>rating</code></td><td>商品的平均评分，通常满分为 5 分。</td><td>浮点数</td></tr><tr><td><code>top_review</code> （可选）</td><td>包含该商品最高评价详情的对象。</td><td>对象</td></tr><tr><td><code>top_review.text</code> （可选）</td><td>最高评价的文本内容</td><td>字符串</td></tr><tr><td><code>top_review.title</code> （可选）</td><td>最高评价的标题。</td><td>字符串</td></tr><tr><td><code>top_review.author</code> （可选）</td><td>最高评价的作者。</td><td>字符串</td></tr><tr><td><code>top_review.rating</code> （可选）</td><td>最高评价作者给出的评分，通常满分为 5 分。</td><td>浮点数</td></tr><tr><td><code>top_review.source</code> （可选）</td><td>发布最高评价的来源或网站。</td><td>字符串</td></tr><tr><td><code>rating_stars</code></td><td>商品的平均评分，通常满分为 5 星。</td><td>浮点数</td></tr><tr><td><code>reviews_count</code> （可选）</td><td>商品的评论总数。</td><td>整数</td></tr><tr><td><code>reviews_by_stars</code></td><td>包含各星级评论数量的对象。</td><td>对象</td></tr><tr><td><code>reviews_by_stars.url</code> （可选）</td><td>包含 X 星评论详情的对象。</td><td>字符串</td></tr><tr><td><code>reviews_by_stars.reviews_count</code></td><td>X 星评论的数量。</td><td>整数</td></tr></tbody></table>

### 相关商品（更多选项）

包含目标商品相关商品的对象数组。

<figure><img src="/files/b7f9043fdde2446515f8c2c0b46e3e9c908fdb6e" alt=""><figcaption></figcaption></figure>

```json
...             
   "related_items": [
      {
        "items": [
          {
            "url": "/search?ibp=oshop&prds=catalogid:1368129371371338580,gpcid:14975392695437189622,headlineOfferDocid:2388507960063782588,imageDocid:1618178582933849531,productid:7780474142858650836,pvo:2,pvt:hg,rds:PC_14975392695437189622%7CPROD_PC_14975392695437189622&q=nvidia+rtx&gl=us&hl=en&pvorigin=2",
            "image": "https://encrypted-tbn3.gstatic.com/shopping?q=tbn:ANd9GcScO-LIdlqj1WjcLznMECFXNo4qbZ1TRbkfHdDsDPoIYxx7S9TjKhnQX7Ah6QsKI-zPBKFrC54H0wGZC60Q_NdRebesvYUXwRhQFuZRwvtWmx4_0xoxbylM",
            "price": 639.99,
            "title": "NVIDIA GeForce RTX 5070 12GB GDDR7 显卡",
            "currency": "USD",
            "reviews_count": 228
          },
...
        ],
        "title": "更多选项"
     }
],
...
```

<table><thead><tr><th width="265">Key(related_items[])</th><th width="350">描述</th><th>类型</th></tr></thead><tbody><tr><td><code>items</code></td><td>包含每个相关商品详情的对象数组。</td><td>数组</td></tr><tr><td><code>items.url</code></td><td>相关商品页面的 URL。</td><td>字符串</td></tr><tr><td><code>items.image</code></td><td>相关商品图片的 URL。</td><td>字符串</td></tr><tr><td><code>items.price</code></td><td>指定货币中的相关商品价格。</td><td>浮点数</td></tr><tr><td><code>items.title</code> （可选）</td><td>相关商品列表的标题。</td><td>字符串</td></tr><tr><td><code>items.rating</code> （可选）</td><td>相关商品的平均用户评分，通常满分为 5 分。</td><td>整数</td></tr><tr><td><code>items.store</code> （可选）</td><td>提供相关商品的商店或商家名称。</td><td>字符串</td></tr><tr><td><code>items.currency</code></td><td>商品价格的货币代码。</td><td>字符串</td></tr><tr><td><code>items.reviews_count</code></td><td>相关商品的评论总数。</td><td>整数</td></tr><tr><td><code>title</code></td><td>相关商品部分的标题或主标题</td><td>字符串</td></tr></tbody></table>

### 规格

包含商品规格详情的对象数组。

<figure><img src="/files/a25c1cfc47688d76fd6d2d269291abd2d373e5b1" alt=""><figcaption></figcaption></figure>

```json
...
"specifications": [
    {
        "items": [
          {
            "title": "制造商",
            "value": "PNY"
          },
          {
            "title": "输出",
            "value": "HDMI, DisplayPort"
          },
          {
            "title": "接口",
            "value": "PCI Express"
          },
          {
            "title": "品牌",
            "value": "PNY"
          },
...
        ],
        "section_title": "属性"
      }
],
...
```

<table><thead><tr><th width="220">Key (specifications[])</th><th width="367">描述</th><th>类型</th></tr></thead><tbody><tr><td><code>items</code></td><td>包含单个规格详情的对象数组。</td><td>数组</td></tr><tr><td><code>items.title</code></td><td>规格的标题。</td><td>字符串</td></tr><tr><td><code>items.value</code></td><td>规格的值。</td><td>字符串</td></tr><tr><td><code>section_title</code></td><td>规格部分的标题或主标题</td><td>字符串</td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developers.oxylabs.io/api-targets/cn/sou-suo-yin-qing/google/shopping/shopping-product.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
