Documentation has been updated: see help center and changelog in one place.

Perplexity

了解如何抓取 Perplexity 的响应并使用网页爬虫 API 获取结构化数据。查找全面的代码示例和输出样本。

perplexity 来源允许你直接向 Perplexity 发送提示并捕获完整响应。它以结构化格式返回生成的文本和相关元数据,并附带结果的 Markdown 版本。

请求示例

以下代码示例展示了如何向 Perplexity 发送提示并获取解析后的响应。

curl 'https://realtime.oxylabs.io/v1/queries' \
--user 'USERNAME:PASSWORD' \
-H 'Content-Type: application/json' \
-d '{
        "source": "perplexity",
        "prompt": "top 3 smartphones in 2025, compare pricing across US marketplaces",
        "geo_location": "United States",
        "parse": true
    }'

默认情况下,所有发往 Perplexity 的请求都会使用 JavaScript 渲染。使用 Realtime 集成方式时,请确保设置足够的超时时间(例如 180s)。

我们的示例使用 Realtime (同步)集成方式。要使用 Proxy EndpointPush-Pull (异步),请参阅 集成方法 页面。

请求参数取值

通用

用于抓取 Perplexity 响应的基础设置与配置参数。

参数
说明
默认值

source

设置爬虫。

perplexity

prompt

提交给 Perplexity 的提示或问题。

-

parse

当设置为 true.

false

geo_location

指定一个国家,从该国家发送提示。 更多信息.

-

callback_url

你的回调端点的 URL。 更多信息.

-

- 必填参数

结构化数据

网页爬虫API 会返回一个 HTML 文档或一个包含 Perplexity 输出的 JSON 对象,其中包含来自结果页的结构化数据。

perplexity structured output
{
  "results": [
    {
      "content": {
        "url": "https://www.perplexity.ai/search/top-3-smartphones-in-2025-comp-wvA0dso7TgW3NpgF8Jd8tg",
        "model": "turbo",
        "top_images": [
          {
            "url": "https://d2u1z1lopyfwlx.cloudfront.net/thumbnails/cca0fd5c-8a96-543c-89ff-3191b4be9c42/57288799-40bc-5d1f-90fe-b936b0a65cd1.jpg",
            "title": "Top Smartphones of 2025 with AI-Driven Features"
          },
          {
            "url": "https://d2u1z1lopyfwlx.cloudfront.net/thumbnails/2cc6543a-e4ef-594b-801f-c5b60308c33a/aec8f940-3469-5597-816f-0dd903b3407c.jpg",
            "title": "The best phone 2025: top smartphones in the US right now ..."
          },
          {
            "url": "https://d2u1z1lopyfwlx.cloudfront.net/thumbnails/26dedbf8-baca-5d1f-ac97-bd70b76c61a3/aec8f940-3469-5597-816f-0dd903b3407c.jpg",
            "title": "Best phones 2025 tested \u2014 Our top picks | Tom's Guide"
          },
          {
            "url": "https://d2u1z1lopyfwlx.cloudfront.net/thumbnails/0a3be7b1-a63d-5c96-b3f5-10b3ab84249c/6a4747ad-0c64-581e-8c1d-a7d907f27628.jpg",
            "title": "Best phones to buy in 2025 reviewed and ranked | Stuff"
          }
        ],
        "top_sources": [
          {
            "url": "https://www.youtube.com/watch?v=EYMe2jy-urg",
            "title": "Top 5 BEST Smartphones of 2025\u2026 So Far - YouTube",
            "source": "youtube"
          },
          {
            "url": "https://www.zdnet.com/article/best-phone/",
            "title": "The best phones to buy in 2025 - ZDNET",
            "source": "ZDNET"
          },
          {
            "url": "https://www.tomsguide.com/best-picks/best-phones",
            "title": "Best phones 2025 tested \u2014 Our top picks | Tom's Guide",
            "source": "Tom's Guide"
          },
          {
            "url": "https://www.wired.com/story/best-cheap-phones/",
            "title": "8 Best Cheap Phones (2025), Tested and Reviewed - WIRED",
            "source": "WIRED"
          }
        ],
        "prompt_query": "top 3 smartphones in 2025, compare pricing across US marketplaces",
        "answer_results": [
          "基于专家评测和市场共识,2025 年前三款智能手机是:",
          {
            "list": [
              [
                [
                  [
                    "Samsung Galaxy S25 Ultra"
                  ]
                ]
              ],
              [
                [
                  [
                    "Apple iPhone 16 Pro Max"
                  ]
                ]
              ],
              [
                [
                  [
                    "Google Pixel 9 Pro XL"
                  ],
                  "(或选择 Pixel 9a 作为高性价比选项)"
                ]
              ]
            ]
          },
          "美国各大平台价格对比(约 MSRP 与市场价):",
          {
            "table": [
              {
                "table_columns": [
                  [
                    "智能手机型号"
                  ],
                  [
                    "MSRP(官方)"
                  ],
                  [
                    "Amazon 价格(2025)"
                  ],
                  [
                    "T-Mobile 价格(2025)"
                  ],
                  [
                    "备注"
                  ]
                ]
              },
              {
                "table_rows": [
                  [
                    [
                      "Samsung Galaxy S25 Ultra"
                    ],
                    [
                      "$1,300"
                    ],
                    [
                      "约 $949.50(256GB)"
                    ],
                    [
                      "约 $830 - $1,000"
                    ],
                    [
                      "价格因存储而异,256GB 版本约 $950;提供 S Pen 和高端相机功能[2][11][12]"
                    ]
                  ],
                  [
                    [
                      "Apple iPhone 16 Pro Max"
                    ],
                    [
                      "$1,200"
                    ],
                    [
                      "约 $1,200"
                    ],
                    [
                      "$830(iPhone 16 基础款)"
                    ],
                    [
                      "Pro Max 型号通常 MSRP 为 $1,200;运营商处基础款 iPhone 16 约 $830 可入手[2][10]"
                    ]
                  ],
                  [
                    [
                      "Google Pixel 9 Pro XL"
                    ],
                    [
                      "$900"
                    ],
                    [
                      "未明确列出"
                    ],
                    [
                      "N/A"
                    ],
                    [
                      "MSRP $900;Pixel 9a 版本在 $500 以下具备很高性价比[2][4][10]"
                    ]
                  ]
                ]
              }
            ]
          },
          "这些智能手机的说明:",
          {
            "list": [
              [
                "Samsung Galaxy S25 Ultra",
                " 被认为是整体最佳手机,配备 6.9\" 大屏、强劲的 Snapdragon 8 Elite 处理器、5000mAh 电池、包括 200MP 传感器在内的多功能相机以及内置 S Pen 生产力功能。价格较高,但在 Amazon 和 T-Mobile 等平台上可低于 MSRP 折扣购入[2][12]。"
              ],
              [
                "Apple iPhone 16 Pro Max",
                " 被视为最佳 iPhone,搭载 Apple 的 A18 Pro Bionic 芯片,同样为 6.9\" 大屏,最高 1TB 存储,MSRP 约 $1,200。通过运营商优惠,基础款 iPhone 16(非 Pro Max)的实际成本有时更低[2][10]。"
              ],
              [
                "Google Pixel 9 Pro XL",
                " 以更低的价位(约 $900)提供扎实的相机与软件体验,搭载 Google 的 Tensor G4。若追求超高性价比,Pixel 9a 提供出色相机与性能且低于 $500,但并非旗舰对手[2][4]。"
              ]
            ]
          },
          "平台概览:",
          {
            "list": [
              [
                [
                  [
                    "Amazon"
                  ],
                  " 通常对旗舰机有小幅折扣——Samsung Galaxy S25 Ultra(256GB)约 $949.50,OnePlus 13 等旗舰也有类似折扣[11][12]。"
                ]
              ],
              [
                [
                  [
                    "如 T-Mobile 等运营商门店"
                  ],
                  " 有时提供分期与促销——iPhone 16 搭配套餐起价约 $830;Samsung Galaxy S25 价格浮动,但在合约下可接近或低于 MSRP[10][11]。"
                ]
              ],
              [
                "其他平台(Best Buy、Walmart)通常与 Amazon 与运营商价格一致,但可能随捆绑与季节性活动而变化。"
              ]
            ]
          },
          "总之,2025 年高端旗舰层主要集中在 Samsung Galaxy S25 Ultra 和 Apple iPhone 16 Pro Max,Google 的 Pixel 9 Pro XL 则是性能强劲且稍更实惠的旗舰替代。价格有波动,但旗舰机在美国市场通常在 $900 至 $1,300 区间,且常能通过 Amazon 与运营商获得折扣[2][10][11][12]。",
          {
            "enumerated_references": [
              {
                "num": 1,
                "url": "https://www.youtube.com/watch?v=EYMe2jy-urg"
              },
              {
                "num": 2,
                "url": "https://www.zdnet.com/article/best-phone/"
              },
              {
                "num": 3,
                "url": "https://www.tomsguide.com/best-picks/best-phones"
              },
              {
                "num": 4,
                "url": "https://www.wired.com/story/best-cheap-phones/"
              },
              {
                "num": 5,
                "url": "https://www.techradar.com/news/best-phone"
              },
              {
                "num": 6,
                "url": "https://www.counterpointresearch.com/insight/top-10-bestselling-smartphones-q1-2025/"
              },
              {
                "num": 7,
                "url": "https://uptradeit.com/blog/what-iphones-will-stop-working"
              },
              {
                "num": 8,
                "url": "https://www.stuff.tv/features/best-phone/"
              },
              {
                "num": 9,
                "url": "https://www.youtube.com/watch?v=93wZbN9tecs"
              },
              {
                "num": 10,
                "url": "https://www.cnet.com/tech/mobile/best-phone/"
              },
              {
                "num": 11,
                "url": "https://www.pcmag.com/picks/the-best-phones"
              },
              {
                "num": 12,
                "url": "https://www.gsmarena.com/best_flagship_phones_buyers_guide-review-2027.php"
              }
            ]
          }
        ],
        "displayed_tabs": [
          "search",
          "images",
          "sources"
        ],
        "related_queries": [
          "2025 年这三款顶级智能手机在美国各平台的价格如何对比",
          "哪些特性让 Galaxy S25 Ultra 在 2025 年脱颖而出",
          "为何 Pixel 9a 虽然更便宜却被认为是高性价比之选",
          "iPhone 16 Pro Max 的定价与 Samsung 和 Google 机型有何不同",
          "2025 年在这些顶级机型中做选择时我应考虑哪些因素"
        ],
        "answer_results_md": "\n基于专家评测和市场共识,2025 年前三款智能手机是:\n\n1. **Samsung Galaxy S25 Ultra**\n2. **Apple iPhone 16 Pro Max**\n3. **Google Pixel 9 Pro XL**(或选择 Pixel 9a 作为高性价比选项)\n\n### 美国各大平台价格对比(约 MSRP 与市场价):\n\n| 智能手机型号               | MSRP(官方) | Amazon 价格(2025)         | T-Mobile 价格(2025) | 备注 |\n|---------------------------|--------------|------------------------------|-----------------------|------|\n| Samsung Galaxy S25 Ultra | $1,300       | 约 $949.50(256GB)          | 约 $830 - $1,000      | 价格因存储而异,256GB 版本约 $950;提供 S Pen 和高端相机功能[2][11][12] |\n| Apple iPhone 16 Pro Max  | $1,200       | 约 $1,200                    | $830(iPhone 16 基础款) | Pro Max 型号通常 MSRP 为 $1,200;运营商处基础款 iPhone 16 约 $830 可入手[2][10] |\n| Google Pixel 9 Pro XL    | $900         | 未明确列出                   | N/A                   | MSRP $900;Pixel 9a 版本在 $500 以下具备很高性价比[2][4][10] |\n\n### 这些智能手机的说明:\n\n- **Samsung Galaxy S25 Ultra** 被认为是整体最佳手机,配备 6.9\" 大屏、强劲的 Snapdragon 8 Elite 处理器、5000mAh 电池、包括 200MP 传感器在内的多功能相机以及内置 S Pen 生产力功能。价格较高,但在 Amazon 和 T-Mobile 等平台上可低于 MSRP 折扣购入[2][12]。\n\n- **Apple iPhone 16 Pro Max** 被视为最佳 iPhone,搭载 Apple 的 A18 Pro Bionic 芯片,同样为 6.9\" 大屏,最高 1TB 存储,MSRP 约 $1,200。通过运营商优惠,基础款 iPhone 16(非 Pro Max)的实际成本有时更低[2][10]。\n\n- **Google Pixel 9 Pro XL** 以更低的价位(约 $900)提供扎实的相机与软件体验,搭载 Google\u2019s Tensor G4。若追求超高性价比,Pixel 9a 提供出色相机与性能且低于 $500,但并非旗舰对手[2][4]。\n\n### 平台概览:\n\n- **Amazon** 通常对旗舰机有小幅折扣——Samsung Galaxy S25 Ultra(256GB)约 $949.50,OnePlus 13 等旗舰也有类似折扣[11][12]。\n- **如 T-Mobile 等运营商门店** 有时提供分期与促销——iPhone 16 搭配套餐起价约 $830;Samsung Galaxy S25 价格浮动,但在合约下可接近或低于 MSRP[10][11]。\n- 其他平台(Best Buy、Walmart)通常与 Amazon 与运营商价格一致,但可能随捆绑与季节性活动而变化。\n\n总之,2025 年高端旗舰层主要集中在 Samsung Galaxy S25 Ultra 和 Apple iPhone 16 Pro Max,Google\u2019s Pixel 9 Pro XL 则是性能强劲且稍更实惠的旗舰替代。价格有波动,但旗舰机在美国市场通常在 $900 至 $1,300 区间,且常能通过 Amazon 与运营商获得折扣[2][10][11][12]。\n\n[1] https://www.youtube.com/watch?v=EYMe2jy-urg\n[2] https://www.zdnet.com/article/best-phone/\n[3] https://www.tomsguide.com/best-picks/best-phones\n[4] https://www.wired.com/story/best-cheap-phones/\n[5] https://www.techradar.com/news/best-phone\n[6] https://www.counterpointresearch.com/insight/top-10-bestselling-smartphones-q1-2025/\n[7] https://uptradeit.com/blog/what-iphones-will-stop-working\n[8] https://www.stuff.tv/features/best-phone/\n[9] https://www.youtube.com/watch?v=93wZbN9tecs\n[10] https://www.cnet.com/tech/mobile/best-phone/\n[11] https://www.pcmag.com/picks/the-best-phones\n[12] https://www.gsmarena.com/best_flagship_phones_buyers_guide-review-2027.php\n",
        "parse_status_code": 12000,
        "additional_results": {
          "images_results": [
            {
              "title": "Top Smartphones of 2025 with AI-Driven Features",
              "image_url": "https://img-cdn.thepublive.com/filters:format(webp)/industry-wired/media/media_files/2025/01/04/A9hU8NmTl0weavNM5Cmb.jpg",
              "image_from_url": "https://industrywired.com/ai/top-smartphones-of-2025-with-ai-driven-features-8590046"
            },
            {
              "title": "The best phone 2025: top smartphones in the US right now ...",
              "image_url": "https://cdn.mos.cms.futurecdn.net/CuSm3XePuDdXHxmbeoZF8M.jpg",
              "image_from_url": "https://www.techradar.com/news/best-phone"
            },
            {
              "title": "Best phones 2025 tested \u2014 Our top picks | Tom's Guide",
              "image_url": "https://cdn.mos.cms.futurecdn.net/M4nigVN3vvA5EEnNX9atxY.jpg",
              "image_from_url": "https://www.tomsguide.com/best-picks/best-phones"
            },
            {
              "title": "Best phones to buy in 2025 reviewed and ranked | Stuff",
              "image_url": "https://www.stuff.tv/wp-content/uploads/sites/2/2024/07/Best-smartphones-on-sale-2024-lead.jpg",
              "image_from_url": "https://www.stuff.tv/features/best-phone/"
            },
            {
              "title": "The best mid-range phones to buy in 2025 - PhoneArena",
              "image_url": "https://m-cdn.phonearena.com/images/article/133911-wide-two_1200/The-best-mid-range-phones-to-buy-in-2025.jpg",
              "image_from_url": "https://www.phonearena.com/news/best-mid-range-phones_id133911"
            },
            {
              "title": "The best smartphones of 2025, tried and tested \u2013 but are ...",
              "image_url": "https://www.telegraph.co.uk/content/dam/recommended/2025/05/20/TELEMMGLPICT000425244583_17477562398800_trans_NvBQzQNjv4BqqVzuuqpFlyLIwiB6NTmJwfSVWeZ_vEN7c6bHu2jJnT8.jpeg?imwidth=640",
              "image_from_url": "https://www.telegraph.co.uk/recommended/tech/best-smartphones/"
            },
            {
              "title": "Best Phones in 2025 | Top-Rated Smartphones and Cellphones ...",
              "image_url": "https://www.cnet.com/a/img/resize/b84fd97fe29bbe2ec4d397caf63db53bf8bea241/hub/2022/03/30/e841545d-e55c-47fc-b24a-003bf14e58c8/oneplus-10-pro-cnet-review-12.jpg?auto=webp&fit=crop&height=900&width=1200",
              "image_from_url": "https://www.cnet.com/tech/mobile/best-phone/"
            },
            {
              "title": "The 7 Best Smartphones to Buy in 2025 - Best Smartphone Reviews",
              "image_url": "https://hips.hearstapps.com/hmg-prod/images/best-smartphones-2025-67afc62def800.jpg?crop=0.503xw:0.671xh;0.338xw,0.218xh&resize=1120:*",
              "image_from_url": "https://www.bestproducts.com/tech/electronics/g60318873/best-smartphones/"
            },
            {
              "title": "Which Smartphones Are Most Popular in 2025? The Winner Might ...",
              "image_url": "https://i.pcmag.com/imagery/articles/00lQQsbajdRLVSbeeBwioC0-2.fit_lim.size_1050x.webp",
              "image_from_url": "https://www.pcmag.com/news/2025-smartphone-sales-rankings-reveal-a-surprise-leader-and-a-red-flag"
            }
          ],
          "sources_results": [
            {
              "url": "https://www.youtube.com/watch?v=EYMe2jy-urg",
              "title": "Top 5 BEST Smartphones of 2025\u2026 So Far - YouTube"
            },
            {
              "url": "https://www.zdnet.com/article/best-phone/",
              "title": "The best phones to buy in 2025 - ZDNET"
            },
            {
              "url": "https://www.tomsguide.com/best-picks/best-phones",
              "title": "Best phones 2025 tested \u2014 Our top picks | Tom's Guide"
            },
            {
              "url": "https://www.wired.com/story/best-cheap-phones/",
              "title": "8 Best Cheap Phones (2025), Tested and Reviewed - WIRED"
            },
            {
              "url": "https://www.techradar.com/news/best-phone",
              "title": "The best phone 2025: top smartphones in the US right now"
            },
            {
              "url": "https://www.counterpointresearch.com/insight/top-10-bestselling-smartphones-q1-2025/",
              "title": "iPhone 16 Leads Global Smartphone Sales in Q1 2025"
            },
            {
              "url": "https://uptradeit.com/blog/what-iphones-will-stop-working",
              "title": "What iPhones Will Stop Working in 2025 - UpTrade"
            },
            {
              "url": "https://www.stuff.tv/features/best-phone/",
              "title": "Best phones to buy in 2025 reviewed and ranked - Stuff"
            },
            {
              "url": "https://www.youtube.com/watch?v=93wZbN9tecs",
              "title": "Best Phones of 2025 (so far) | Mid-Range, Camera, Gaming & More"
            },
            {
              "url": "https://www.cnet.com/tech/mobile/best-phone/",
              "title": "Best Phones in 2025 | Top-Rated Smartphones and ... - CNET"
            },
            {
              "url": "https://www.pcmag.com/picks/the-best-phones",
              "title": "The Best Phones We've Tested (July 2025) - PCMag"
            },
            {
              "url": "https://www.gsmarena.com/best_flagship_phones_buyers_guide-review-2027.php",
              "title": "Best flagship phones 2025 - buyer's guide - GSMArena.com tests"
            }
          ]
        }
      },
      "created_at": "2025-07-16 12:14:32",
      "updated_at": "2025-07-16 12:15:28",
      "page": 1,
      "url": "https://www.perplexity.ai/search/top-3-smartphones-in-2025-comp-wvA0dso7TgW3NpgF8Jd8tg",
      "job_id": "7351222707934990337",
      "is_render_forced": false,
      "status_code": 200,
      "parser_type": "perplexity",
      "parser_preset": null
    }
  ]
}

输出数据字典

HTML 示例

JSON 结构

该结构化 perplexity 输出包含以下字段,例如 url, model, answer_results,以及更多。下表拆解我们解析的页面元素,并附说明、数据类型和相关元数据。

特定结果类型的条目与字段数量可能随提交的提示而变化。

字段
说明
类型

url

Perplexity 会话的 URL。

string

page

页码。

integer

content

包含已解析 Perplexity 页面数据的对象。

object

model

用于生成答案的 Perplexity 模型。

string

prompt_query

提交给 Perplexity 的原始提示。

string

displayed_tabs

Perplexity 界面中显示的选项卡(例如购物、图片)。

list

answer_results

包含文本或嵌套内容的完整 Perplexity 响应。

list 或 string

answer_results_md

以 Markdown 格式呈现的完整答案。

string

related_queries

与主提示相关的查询列表。

list

top_images

包含标题和 URL 的热门图片列表。

array

top_sources

包含标题、来源和 URL 的主要引用来源列表。

array

inline_products

包含标题、价格、链接和其他元数据的内联产品列表。

array

additional_results.hotels_results

包含标题、URL、地址及其他酒店详情的酒店列表。

array

additional_results.places_results

包含标题、URL、坐标及其他元数据的地点列表。

array

additional_results.videos_results

包含缩略图、标题、URL 和来源的视频列表。

array

additional_results.shopping_results

包含标题、价格、URL 和其他产品元数据的购物商品列表。

array

additional_results.sources_results

包含标题和 URL 的引用来源列表。

array

additional_results.images_results

包含标题、图片 URL 和来源页面 URL 的相关图片列表。

array

parse_status_code

解析操作的状态码。

integer

created_at

抓取任务创建的时间戳。

timestamp

updated_at

抓取任务完成的时间戳。

timestamp

job_id

与抓取任务关联的作业 ID。

string

geo_location

提交提示时所使用的代理位置。

string

status_code

抓取任务的状态码。你可以在此处查看爬虫状态码的描述 here.

integer

parser_type

用于解析 HTML 内容的解析器类型。

string

附加结果和内联产品

除了主要的 AI 响应外,我们还在 additional_results下返回额外的数据,例如

  • images_results

  • sources_results

  • shopping_results

  • videos_results

  • places_results

  • hotels_results

这些数组从原始结果页面的选项卡中提取,仅在存在相关内容时包含:

此外, inline_products array 包含直接嵌入在响应中的产品:

最后更新于

这有帮助吗?