> 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` 该源从 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` 参数必须包含通过以下方式生成的有效 token `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="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>设置为时启用 JavaScript 渲染 <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>desktop</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.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": "My computer is a Dell Optiplex 9020, i7-4770, 32mb, 500gb SSD. The 3 fan card is a long, and the hard drive cage had to be removed to fit in the Optiplex case. The power supply was upgraded to 750 watts which required an adapter for the Dell motherboard. With those modifications out of the way, installation of the card was drama free, but you have use Google to find the driver in the Nvidia website. I am using this GPU for 3D animation in Blender. I am very pleased with the speed of the rendering with ray tracing in EEVEE and Cycles. As this is an old computer, the computer's CPU never runs at 100%, and I haven't been able to max out this card's capacity yet. I don't hear the fans running but I have never put a high load enough on it yet, I guess. It does have a little electronic buzz when it is rendering.\u00a0Less",
        "author": "walmart.com Shopper",
        "rating": 5,
        "source": "Reviewed on walmart.com"
      },
      "rating_stars": 4.7,
      "reviews_count": 51,
      "review_count_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>review_count_by_stars</code></td><td>一个包含每个星级评论数量的对象。</td><td>对象</td></tr><tr><td><code>review_count_by_stars.url</code> （可选）</td><td>一个包含 X 星评论详情的对象。</td><td>字符串</td></tr><tr><td><code>review_count_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 Graphics Card",
            "currency": "USD",
            "reviews_count": 228
          },
...
        ],
        "title": "More options"
     }
],
...
```

<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": "Manufacturer",
            "value": "PNY"
          },
          {
            "title": "Output",
            "value": "HDMI, DisplayPort"
          },
          {
            "title": "Interface",
            "value": "PCI Express"
          },
          {
            "title": "Brand",
            "value": "PNY"
          },
...
        ],
        "section_title": "attributes"
      }
],
...
```

<table><thead><tr><th width="220">Key (specifications[])</th><th width="367">描述</th><th>类型</th></tr></thead><tbody><tr><td><code>items.title</code></td><td>规格标题。</td><td>字符串</td></tr><tr><td><code>items.value</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.
