购物商品
使用 Web Scraper API 检索详细的 Google Shopping 商品数据,包括价格、评论、规格和变体。
该 google_shopping_product source 使用一个从 Google Shopping 获取的详细产品信息(标题、描述、价格、卖家、相关商品、评论等)的 产品令牌 从…获取 google_shopping_search source.
请求示例
在下面的代码示例中,我们使用有效令牌发起请求以检索 Google Shopping 产品的商品页面。
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
}'import requests
from pprint import pprint
# 构建负载(payload)。
payload = {
"source": "google_shopping_product",
"query": "[product_token_string]",
"render": "html",
"parse": True
}
# 获取响应。
response = requests.request(
'POST',
'https://realtime.oxylabs.io/v1/queries',
auth=('USERNAME', 'PASSWORD'),
json=payload,
)
# 将美化后的响应打印到标准输出。
pprint(response.json())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();https://realtime.oxylabs.io/v1/queries?source=google_shopping_product&query=[product_token_string]&parse=true&access_token=12345abcde<?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);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))
}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);
}
}
}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();
}
}{
"source": "google_shopping_product",
"query": "[product_token_string]",
"render": "html",
"parse": true
}在我们的示例中,我们使用同步的 Realtime 集成方法。如果您想使用 Proxy Endpoint 或异步的 Push-Pull 集成,请参阅 集成方法 部分。
请求参数值
通用
用于抓取 Google Shopping 产品页面的基本设置和自定义选项。
- 必填参数
本地化
将结果适配到特定的地理位置、域名和语言。
注意: 确保你的本地化参数用于 google_shopping_product 和 google_shopping_search 来源相同(未定义时为无)。来源之间的区域不一致可能导致不完整或不准确的数据。
结构化数据
下面您可以找到一个 结构化输出示例 用于 google_shopping_product.
输出数据字典
HTML 示例

JSON 结构
下表列出了我们解析的每个产品页面元素的详细清单、说明和数据类型。表中还包括一些元数据。
url
指向 Google Shopping 产品页面的 URL。
字符串
title
商品列表的标题。
字符串
description
产品的详细描述。
字符串
images
包含产品图片的对象。
对象
images.full_size
产品全尺寸图片 URL 的数组。
数组
images.thumbnails
产品缩略图 URL 的数组。
数组
pricing
包含所有在线定价信息的数组。
数组
评价
包含评论信息的对象。(仅限美国)
对象
variants
包含产品变体的对象数组。(颜色、尺寸等)
数组
related_items
包含相关商品的对象数组。
数组
specifications
包含产品规格的对象数组。
数组
created_at
抓取任务创建的时间戳。
时间戳
updated_at
抓取任务完成的时间戳。
时间戳
job_id
与抓取任务关联的作业 ID。
字符串
定价
包含产品定价信息的对象。

...
"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
},
...
]
},
...online
包含产品定价详情的对象数组。
数组
online.price
以指定货币表示的产品价格。
float
online.seller
提供该产品的卖家或商家的名称。
字符串
online.details
关于产品或购买的附加信息,例如交付和退货政策。
字符串
online.currency
产品价格的货币代码。
字符串
online.condition
商品的状态或成色。
字符串
online.price_tax
应用于产品价格的税额。
float
online.price_total (可选)
包括税费在内的产品总价。
float
online.seller_link
指向该产品卖家页面的 URL。
字符串
online.price_shipping
产品的运费。
float
评论
包含产品评论和评分信息的对象。

...
"reviews": {
"rating": 4.7,
"top_review": {
"text": "我的电脑是 Dell Optiplex 9020,i7-4770,32mb,500gb SSD。三风扇显卡较长,必须移除硬盘笼才能安装进 Optiplex 机箱。电源升级到 750 瓦,这需要为 Dell 主板使用适配器。完成这些修改后,安装显卡没有问题,但需要通过 Google 在 Nvidia 网站上找到驱动。我在 Blender 中将此 GPU 用于 3D 动画。对在 EEVEE 和 Cycles 中使用光线追踪渲染的速度非常满意。由于这是台较旧的电脑,CPU 从未达到 100%,我还未能完全发挥此显卡的性能。我没有听到风扇运转的声音,但我还没有给它施加足够高的负载,估计会有。渲染时会有轻微的电子嗡嗡声。\u00a0更少",
"author": "walmart.com Shopper",
"rating": 5,
"source": "Reviewed on 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
}
},
},
...rating
产品的平均评分,通常以 5 分为满分。
float
top_review
包含产品最有代表性评论详情的对象。
对象
top_review.text (可选)
最有代表性评论的文本内容。
字符串
top_review.title (可选)
最有代表性评论的标题。
字符串
top_review.author
最有代表性评论的作者。
字符串
top_review.rating
最有代表性评论作者给出的评分,通常以 5 分为满分。
float
top_review.source
最有代表性评论发布的来源或网站。
字符串
rating_stars
产品的平均评分,通常以 5 星为满分。
float
reviews_count (可选)
该产品的评论总数。
整数
reviews_by_stars
包含每个星级评分评论计数的对象。
对象
reviews_by_stars.url (可选)
包含 X 星评论详情的对象。
字符串
reviews_by_stars.reviews_count
X 星评论的数量。
整数
相关商品(更多选项)
包含目标产品相关商品的对象数组。

...
"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"
}
],
...items
包含每个相关商品详情的对象数组。
数组
items.url
相关产品页面的 URL。
字符串
items.image
相关产品图片的 URL。
字符串
items.price
相关产品以指定货币表示的价格。
float
items.title (可选)
相关产品列表的标题。
字符串
items.rating (可选)
相关产品的平均用户评分,通常以 5 分为满分。
整数
items.store (可选)
提供相关产品的商店或商家的名称。
字符串
items.currency
产品价格的货币代码。
字符串
items.reviews_count
相关产品的评论总数。
整数
title
相关商品部分的标题或标题。
字符串
规格
包含产品规格详情的对象数组。

...
"specifications": [
{
"items": [
{
"title": "Manufacturer",
"value": "PNY"
},
{
"title": "Output",
"value": "HDMI, DisplayPort"
},
{
"title": "Interface",
"value": "PCI Express"
},
{
"title": "Brand",
"value": "PNY"
},
...
],
"section_title": "attributes"
}
],
...items
包含单个规格详情的对象数组。
数组
items.title
规格的标题。
字符串
items.value
规格的数值或内容。
字符串
section_title
规格部分的标题或标题。
字符串
最后更新于
这有帮助吗?

