商品
了解如何使用 Web Scraper API 获取 Walmart 商品页面数据。了解请求参数和结构化数据输出。
该 walmart_product source 旨在检索 Walmart 产品结果页面。我们可以返回任何您想要的 Walmart 页面 HTML。此外,我们还能提供 Walmart 产品页面的结构化(已解析)输出.
请求示例
下面的示例展示了如何获取已解析的 Walmart 产品页面结果。
curl 'https://realtime.oxylabs.io/v1/queries' \
--user 'USERNAME:PASSWORD' \
-H 'Content-Type: application/json' \
-d '{
"source": "walmart_product",
"product_id": "15296401808",
"parse": true
}'import requests
from pprint import pprint
# 构建负载(payload)。
payload = {
'source': 'walmart_product',
'product_id': '15296401808',
'parse': True,
}
# 获取响应。
response = requests.request(
'POST',
'https://realtime.oxylabs.io/v1/queries',
auth=('USERNAME', 'PASSWORD'),
json=payload,
)
# 与返回作业状态和结果 URL 的响应不同,此调用将直接返回
# 带结果的 JSON 响应。
pprint(response.json())const https = require("https");
const username = "USERNAME";
const password = "PASSWORD";
const body = {
source: "walmart_product",
product_id: "15296401808",
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();# 您提交的整个字符串必须进行 URL 编码。
https://realtime.oxylabs.io/v1/queries?source=walmart_product&product_id=15296401808&parse=true&access_token=12345abcde<?php
$params = array(
'source' => 'walmart_product',
'product_id' => '15296401808',
'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": "walmart_product",
"product_id": "15296401808",
"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 = "walmart_product",
product_id = "15296401808",
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", "walmart_product");
jsonObject.put("product_id", "15296401808");
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": "walmart_product",
"product_id": "15296401808",
"parse": true
}在我们的示例中,我们使用同步的 Realtime 集成方法。如果您想使用 Proxy Endpoint 或异步的 Push-Pull 集成,请参阅 集成方法 部分。
请求参数值
通用
- 必填参数
本地化
将结果适配到特定门店、送货地点。Walmart 门店 ID 的 JSON 列表见此处:
您也可以找到沃尔玛门店的官方页面 此处.
domain
沃尔玛的域名本地化。
字符串
delivery_zip
设置收货邮编位置。
字符串
store_id
设置门店位置。
字符串
结构化数据
输出数据字典
HTML 示例

JSON 结构
下表列出了我们解析的每个产品页面元素的详细清单、说明和数据类型。表中还包括一些元数据。
general
包含一般产品页面结果详情的对象。
对象
价格
对象包含有关产品定价的详细信息。
对象
rating
产品的评分信息。
对象
卖家
有关卖家的信息。
对象
variations (可选)
产品的可选变体列表。
数组
breadcrumbs
指向产品的类别层级。
对象
位置
提供请求运行时位置信息。
对象
fulfillment
对象包含有关产品履约选项的信息。
对象
specifications
详细的键值对数组,列出产品的具体属性或特征。
数组
created_at
抓取任务创建的时间戳。
时间戳
updated_at
抓取任务完成的时间戳。
时间戳
page
提取产品数据时所在的页码
整数
url
产品页面在 Walmart 网站上的 URL
字符串
job_id
与抓取任务关联的作业 ID。
字符串
is_render_forced
标识此请求是否已强制渲染。
boolean
parser_type
用于提取数据的解析器类型(例如:"walmart_product_new")。
字符串
常规

url
商品的 URL。
字符串
main_image
主要产品图片的 URL
整数
images
产品图片的 URL 数组。
数组
title
产品的标题或名称。
字符串
description
产品的详尽描述。
字符串
brand
产品的品牌。
字符串
badge
指示特定属性,如促销、产品特征、认证或品牌关联。
字符串列表
meta
产品的元数据。
对象
meta.sku
产品的库存单位(SKU)。
字符串
meta.gtin
产品的全球贸易项目编号(GTIN)。
字符串
价格

...
"price": {
"price": 12.49,
"price_strikethrough": 23.72,
"currency": "USD"
},
...价格
产品当前价格(未扣减)。
float
price_strikethrough
划线价可以是曾经价格、组合价或标价。
float
货币
产品价格的 ISO 4217 三字母货币代码。
字符串
评分

...
"rating": {
"count": 64,
"rating": 4.7
},
...rating
产品的平均评分。
float
count
产品的评分数量。
整数
卖家

...
"seller": {
"id": "ED6F630F4BA94318A00A1D0BAACD0A48",
"url": "/seller/7648?itemId=701606028&pageName=item&returnUrl=%2Fip%2FApple-iPhone-Xs-64GB-Unlocked-GSM-CDMA-4G-LTE-Phone-w-Dual-12MP-Camera-Gold-Fair-Cosmetics-Fully-Functional%2F701606028",
"name": "Kiss Electronics Inc",
"catalog_id": "7648",
"official_name": "Kiss Electronics Inc"
},
...name
卖家的名称。
字符串
official_name
卖方实体的官方注册名称。
字符串
id
平台分配给卖家的唯一标识符。
字符串
url
指向卖家官方网站或店铺的 URL。
字符串
catalog_id
目录 ID。
字符串
规格

...
"specifications": [
...
{
"key": "Brand",
"value": "LEGO"
},
{
"key": "Age Range",
"value": "9 Years & Up"
},
]
...key
产品的具体属性或特征。
字符串
value
由规格键指定的属性对应的值或说明。
字符串
履约

...
"fulfillment": {
"pickup": false,
"delivery": false,
"shipping": true,
"out_of_stock": false,
"free_shipping": true,
"pickup_information": "Pickup, Not available",
"delivery_information": "Delivery, Not available",
"shipping_information": "Shipping, Arrives Oct 24, Free"
},
...pickup
指示产品是否可通过门店自提履约。
boolean
pickup_information
当 pickup = true 时的自提消息。
字符串
delivery
指示该产品是否可通过本地门店配送履约。
boolean
delivery_information
当 delivery = true 时的本地门店配送消息。
字符串
运输
指示产品是否可通过家庭运输履约。
boolean
shipping_information
如果显示,产品的运输信息消息。
字符串
free_shipping
指示运费是否为免费。
boolean
out_of_stock
指示该产品当前是否缺货。
boolean
Variations

...
"variations": [
{
"state": "IN_STOCK",
"product_id": "7328JAQF0Y2S",
"selected_options": [
{
"key": "Color",
"value": "Black"
},
]
...state
产品变体的可用性状态。
字符串
product_id
每个产品变体的唯一标识符。
字符串
selected_options
包含定义变体的已选选项的数组。
数组
selected_options.key
描述所选选项的键。
字符串
selected_options.value
所选选项的值。
字符串
Breadcrumbs

...
"breadcrumbs": [
{
"url": "/cp/cell-phones/1105910",
"category_name": "Cell Phones"
},
{
"url": "/cp/phones-with-plans/1073085",
"category_name": "Phones With Plans"
},
{
"url": "/cp/postpaid-phones/8230659",
"category_name": "Postpaid Phones"
}
...
],
...category_name
类别的名称。
字符串
url
类别的 URL
字符串
位置

...
"location": {
"city": "Sacramento",
"state": "CA",
"store_id": "8915",
"zip_code": "95829"
},
...city
请求运行时所在的城市。
字符串
state
请求运行时所在的州。
字符串
zip_code
请求运行时使用的邮政编码。
字符串
store_id
请求运行时使用的门店 ID。
字符串
最后更新于
这有帮助吗?

