> ## Documentation Index
> Fetch the complete documentation index at: https://help.decodo.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 沃尔玛搜索

> 网页抓取 API 沃尔玛搜索模板

<Danger>
  核心版和高级版套餐已停止销售。请考虑迁移到一体化网络爬虫 API；[请点击此处查看指南](https://help.decodo.com/docs/cn/web-scraping-api-migration-guide).
</Danger>

`walmart_search` 模板用于获取沃尔玛搜索结果信息。

<Note>
  ### 有用链接

  * 此目标适用于 **Web API Advanced 计划**。
  * 此模板支持[**实时**](https://help.decodo.com/docs/cn/web-scraping-api-real-time-requests)和[**异步**](https://help.decodo.com/docs/cn/web-scraping-api-asynchronous-requests)集成方法
  * 还支持[**批量**](https://help.decodo.com/docs/cn/web-scraping-api-asynchronous-requests#queue-multiple-tasks)请求。
</Note>

## 输入参数

沃尔玛搜索模板可用的请求参数：

| 参数                  | 类型      | 必需 | 描述                                                                                                                                                                                                                                     |
| ------------------- | ------- | -- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `target`            | string  | ✅  | 目标类型必须设置为 `walmart_search`                                                                                                                                                                                                             |
| `query`             | string  | ✅  | 搜索查询。                                                                                                                                                                                                                                  |
| `headless`          | string  |    | `html` 值启用 JavaScript 渲染。[**了解更多。**](https://help.decodo.com/docs/cn/web-scraping-api-javascript-rendering-deprecated)<br />`png` 值启用截图响应。[**了解更多。**](https://help.decodo.com/docs/cn/web-scraping-api-screenshot-response-deprecated) |
| `parse`             | boolean |    | 设置为 `true` 时自动解析结果。<br />默认值为 `false`。                                                                                                                                                                                                 |
| `device_type`       | string  |    | 指定设备类型和浏览器。[**了解更多。**](https://help.decodo.com/docs/cn/web-scraping-api-device-types-deprecated)                                                                                                                                       |
| `min_price`         |         |    | 定义最低价格。                                                                                                                                                                                                                                |
| `max_price`         |         |    | 定义最高价格。                                                                                                                                                                                                                                |
| `sort_by`           | string  |    | 使用可用选项定义搜索结果页面的排序方法：`price_low`、`price_high`、`best_seller`、`best_match`。                                                                                                                                                               |
| `domain`            | string  |    | 指定顶级域名。                                                                                                                                                                                                                                |
| `fulfillment_speed` | string  |    | 使用可用选项定义配送速度：`today`、`2_days`、`anytime`、`tomorrow`。                                                                                                                                                                                    |
| `fulfillment_type`  | string  |    | 使用可用选项定义配送类型：`in_store`。                                                                                                                                                                                                               |
| `delivery_zip`      | string  |    | 设置配送地点的邮政编码。选择 `delivery` 或 `shipping` 配送方式时必须设置。                                                                                                                                                                                      |
| `store_id`          | string  |    | 3 到 4 个字符的 Target 商店 ID。选择 `pickup` 配送方式时必须设置。                                                                                                                                                                                         |
| `markdown`          | boolean |    | 设置为 `true` 以接收 Markdown 响应。[**了解更多。**](https://help.decodo.com/docs/cn/web-scraping-api-markdown-response-deprecated)<br />默认值为 `false`。                                                                                               |

### 请求示例

<CodeGroup>
  ```shellscript cURL theme={null}
  # 将 'TOKEN VALUE' 更新为您的授权令牌
  curl --request 'POST' \
          --url 'https://scraper-api.decodo.com/v2/scrape' \
          --header 'Accept: application/json' \
          --header 'Authorization: Basic TOKEN VALUE' \
          --header 'Content-Type: application/json' \
          --data '
      {
        "target": "walmart_search",
        "query": "laptop",
        "headless": "html",
        "parse": true,
      }
  '
  ```

  ```javascript Node theme={null}

  const scrape = async() => {
    const response = await fetch("https://scraper-api.decodo.com/v2/scrape", {
      method: "POST",
      body: JSON.stringify({
        "target": "walmart_search",
        "query": "laptop",
        "headless": "html",
        "parse": true
      }),
      headers: {
        "Content-Type": "application/json",
        "Authorization": "Basic TOKEN VALUE" // 更新为您的授权令牌
      },
    }).catch(error => console.log(error));

    console.log(await response.json())
  }

  scrape()
  ```

  ```python Python theme={null}
  import requests
    
  url = "https://scraper-api.decodo.com/v2/scrape"
    
  payload = {
        "target": "walmart_search",
        "query": "laptop",
        "headless": "html",
        "parse": True
  }
    
  headers = {
      "accept": "application/json",
      "content-type": "application/json",
      "authorization": "Basic TOKEN VALUE" # 更新为您的授权令牌
  }
    
  response = requests.post(url, json=payload, headers=headers)
    
  print(response.text)
  ```
</CodeGroup>

## 输出

下表提供了解析后的 `JSON` `results.organic` 部分中字段的描述。请注意，字段数量可能会根据提供的搜索查询而有所不同。

| 结果键           | 描述                             |
| ------------- | ------------------------------ |
| `price`       | 包含价格信息的对象。                     |
| `rating`      | 包含评分信息的对象。                     |
| `seller`      | 包含卖家信息的对象。                     |
| `general`     | 包含产品详细信息的对象，例如位置、url、徽章、图片、标题。 |
| `fulfillment` | 包含配送信息的对象                      |

#### 响应示例

<CodeGroup>
  ```json JSON expandable theme={null}
  {
    "results": [
        {
            "content": {
                "results": {
                    "url": "https://www.walmart.com/search?q=laptop",
                    "facets": [
                        {
                            "type": "sort",
                            "values": [
                                {
                                    "name": "Best Match"
                                },
                                {
                                    "name": "Price: Low to High"
                                },
                                {
                                    "name": "Price: High to Low"
                                },
                                {
                                    "name": "Best Seller"
                                }
                            ],
                            "display_name": "Sort by"
                        },
                        {
                            "max": 1200,
                            "min": 0,
                            "type": "price",
                            "display_name": "Price"
                        },
                        {
                            "type": "brand",
                            "values": [
                                {
                                    "name": "HP"
                                },
                                {
                                    "name": "Acer"
                                },
                                {
                                    "name": "ASUS"
                                },
                                {
                                    "name": "Lenovo"
                                },
                                {
                                    "name": "RNRUO"
                                },
                                {
                                    "name": "Apple"
                                },
                                {
                                    "name": "Dell"
                                },
                                {
                                    "name": "MSI"
                                },
                                {
                                    "name": "AEEZO"
                                },
                                {
                                    "name": "Microsoft"
                                }
                            ],
                            "display_name": "Brand"
                        }
                    ],
                    "results": [
                        {
                            "price": {
                                "price": 329,
                                "currency": "USD"
                            },
                            "rating": {
                                "count": 432,
                                "rating": 4.4
                            },
                            "seller": {
                                "id": "F55CDC31AB754BB68FE0B39041159D63",
                                "name": "Walmart.com"
                            },
                            "general": {
                                "pos": 1,
                                "url": "/ip/Dell-15-Laptop-DC15255-15-6-inch-FHD-Touchscreen-AMD-Ryzen-5-7530U-8GB-RAM-512GB-SSD-Black/16850267012?classType=REGULAR",
                                "image": "https://i5.walmartimages.com/seo/Dell-15-Laptop-DC15255-15-6-inch-FHD-Touchscreen-AMD-Ryzen-5-7530U-8GB-RAM-512GB-SSD-Black_96712015-40ba-40b1-ac1d-315f97c73c3a.036f982ec54f60dbffb3d558fdb1756a.jpeg?odnHeight=180&odnWidth=180&odnBg=FFFFFF",
                                "title": "Dell 15 Laptop DC15255 - 15.6-inch FHD Touchscreen, AMD Ryzen 5-7530U, 8GB RAM, 512GB SSD, Black",
                                "sponsored": true,
                                "product_id": "16850267012",
                                "out_of_stock": false,
                                "section_title": "Results for \"laptop\""
                            },
                            "fulfillment": {
                                "pickup": false,
                                "delivery": false,
                                "shipping": true,
                                "free_shipping": true
                            }
                        }
                    ],
                    "location": {
                        "city": "Sacramento",
                        "state": "CA",
                        "zipcode": "95829",
                        "store_id": "3081"
                    },
                    "page_details": {
                        "page": 1,
                        "total_results": 22110,
                        "last_visible_page": 15
                    },
                    "parse_status_code": 12000
                },
                "errors": [],
                "status_code": 12000,
                "task_id": "7412770805102164993"
            }
        }
    ]
  }
  ```
</CodeGroup>

***

<Columns cols={2}>
  <Card title="支持" href="https://direct.lc.chat/12092754" cta="让我们聊聊！">
    需要帮助或只是想打个招呼？我们的支持团队全天候为您服务。 \
    您也可以随时通过电子邮件 [support@decodo.com](mailto:support@decodo.com) 联系我们。
  </Card>

  <Card title="反馈" href="mailto:feedback@decodo.com" cta="分享反馈">
    找不到您要找的内容？请求一篇文章！ \
    有反馈意见？分享您对我们如何改进的想法。
  </Card>
</Columns>
