Realtime

Oxylabs 的 Web Scraper API 的 Realtime 集成。在从任务提交直到返回结果或错误期间保持 HTTPS 连接打开,使用 JSON 格式的负载。

Realtime 是一种同步集成方法。它 需要保持连接打开 直到作业成功完成或返回错误。

作业提交

端点

用于提交作业的 Realtime API 端点为:

POST https://realtime.oxylabs.io/v1/queries

输入

按照下面示例的格式在 JSON 有效载荷中提供作业参数。Python 和 PHP 示例包含注释以便说明。

curl --user "USERNAME:PASSWORD" \
'https://realtime.oxylabs.io/v1/queries' \
-H "Content-Type: application/json" \
-d '{"source": "universal", "url": "https://example.com", "geo_location": "United States"}'

输出

Realtime API 在输出中支持以下结果类型:

  • HTML:从目标网页抓取的原始 HTML 内容;

  • JSON:从 HTML 内容解析出的结构化数据,格式为 JSON;

  • PNG:以 Base64 编码的已渲染页面 PNG 格式截图。

  • XHR: 在加载页面时发起的 XHR 请求。 加载页面时发起的 XHR 请求。

  • Markdown: 网页的 Markdown。 网页的 Markdown 内容。

circle-info

你还可以检索 多种结果类型 在单个 API 响应中。

下表说明了基于 API 请求有效载荷中包含的参数的默认和其他可用结果类型。

Render 参数
Parse 参数
默认输出
可用输出

x

x

html

html

html

x

html

html

png

x

png

html, png

x

true

json

html, json

html

true

json

html, json

png

true

png

html, json, png

circle-info

Realtime API 始终返回默认输出。要获取其他可用输出,请使用 {Push-Pullarrow-up-right} 集成方法。

输出示例:

最后更新于

这有帮助吗?