oxylabs-web-scraper
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseOxylabs Web Scraper API
Oxylabs Web Scraper API
Authentication
身份验证
Requires HTTP Basic Auth with credentials from environment variables:
bash
curl -u "$OXY_WSA_USERNAME:$OXY_WSA_PASSWORD" ...需要使用环境变量中的凭证进行HTTP Basic Auth认证:
bash
curl -u "$OXY_WSA_USERNAME:$OXY_WSA_PASSWORD" ...Endpoint
端点
POST https://realtime.oxylabs.io/v1/queries # immediate response
POST https://data.oxylabs.io/v1/queries # Push-Pull jobs, callbacks, storage
Content-Type: application/jsonPOST https://realtime.oxylabs.io/v1/queries # 即时响应
POST https://data.oxylabs.io/v1/queries # 推拉式任务、回调、存储
Content-Type: application/jsonCore Parameters
核心参数
| Parameter | Required | Description |
|---|---|---|
| Yes | Target scraper (e.g., |
| Conditional | URL to scrape (for |
| Conditional | Search query or product ID (for |
| No | Enable structured data parsing (recommended for supported sources) |
| No | JavaScript rendering: |
| No | Geographic targeting: country/state/city, ZIP/postcode, coordinates, or Criteria ID where supported |
| No | Reuse the same proxy IP across multiple jobs |
| No | Set to |
| No | Device/browser preset, e.g., |
| No | Interface language / |
| No | Push-Pull callback endpoint |
| No | Push-Pull cloud upload target ( |
| No | Enable markdown or captured XHR result types |
| No | Rendered browser actions; requires |
| No | Custom parser rules or saved preset; pair with |
| No | Client-side job tag saved with the job metadata |
| Source-specific | Marketplace/search/store localization and pagination fields |
user_agent_typedesktopdesktop_chromedesktop_edgedesktop_firefoxdesktop_operadesktop_safarimobilemobile_androidmobile_iostablettablet_androidtablet_ios| 参数 | 是否必填 | 描述 |
|---|---|---|
| 是 | 目标抓取器(例如: |
| 可选 | 要抓取的URL(适用于 |
| 可选 | 搜索查询或产品ID(适用于 |
| 否 | 启用结构化数据解析(推荐在支持的source中使用) |
| 否 | JavaScript渲染: |
| 否 | 地理定位:国家/州/城市、邮政编码、坐标,或支持的Criteria ID |
| 否 | 在多个任务中复用相同的代理IP |
| 否 | 当通过即时接口或推拉式接口下载图片文件时,设置为 |
| 否 | 设备/浏览器预设,例如: |
| 否 | 界面语言 / |
| 否 | 推拉式任务的回调端点 |
| 否 | 推拉式任务的云上传目标( |
| 否 | 启用markdown或捕获的XHR结果类型 |
| 否 | 渲染浏览器操作;需要配合 |
| 否 | 自定义解析规则或已保存的预设;需配合 |
| 否 | 与任务元数据一起保存的客户端任务标签 |
| 源特定 | 商城/搜索/店铺本地化及分页字段 |
user_agent_typedesktopdesktop_chromedesktop_edgedesktop_firefoxdesktop_operadesktop_safarimobilemobile_androidmobile_iostablettablet_androidtablet_iosContext Parameters
上下文参数
Add these as objects in :
{ "key": "...", "value": ... }context| Key | Use |
|---|---|
| Merge custom headers with managed headers |
| Merge custom cookies with managed cookies |
| Use |
| Follow 3xx redirect chains |
| Treat specific non-standard HTTP codes as successful |
For multi-format output, enable types in the payload (, , , ) and request them with .
parsemarkdownxhrrender: "png"?type=raw,parsed,png,markdown,xhrFor batch Push-Pull jobs, use with arrays only for or ; keep all other parameters singular. Maximum batch size is 5,000 values.
POST /v1/queries/batchqueryurl以对象形式添加到中:
{ "key": "...", "value": ... }context| 键 | 用途 |
|---|---|
| 将自定义请求头与管理请求头合并 |
| 将自定义Cookie与管理Cookie合并 |
| 使用 |
| 跟随3xx重定向链 |
| 将特定非标准HTTP状态码视为成功 |
如需多格式输出,在请求体中启用对应类型(、、、),并通过参数指定请求的类型。
parsemarkdownxhrrender: "png"?type=raw,parsed,png,markdown,xhr对于批量推拉式任务,使用接口,仅或参数可使用数组形式;其余所有参数需保持单个值。最大批量大小为5000个值。
POST /v1/queries/batchqueryurlQuick Start
快速开始
Scrape any URL:
bash
curl -X POST 'https://realtime.oxylabs.io/v1/queries' \
-u "$OXY_WSA_USERNAME:$OXY_WSA_PASSWORD" \
-H 'Content-Type: application/json' \
-d '{"source": "universal", "url": "https://example.com"}'Google search with parsing:
bash
curl -X POST 'https://realtime.oxylabs.io/v1/queries' \
-u "$OXY_WSA_USERNAME:$OXY_WSA_PASSWORD" \
-H 'Content-Type: application/json' \
-d '{"source": "google_search", "query": "best laptops", "parse": true}'Amazon product by ASIN:
bash
curl -X POST 'https://realtime.oxylabs.io/v1/queries' \
-u "$OXY_WSA_USERNAME:$OXY_WSA_PASSWORD" \
-H 'Content-Type: application/json' \
-d '{"source": "amazon_product", "query": "B07FZ8S74R", "parse": true}'抓取任意URL:
bash
curl -X POST 'https://realtime.oxylabs.io/v1/queries' \
-u "$OXY_WSA_USERNAME:$OXY_WSA_PASSWORD" \
-H 'Content-Type: application/json' \
-d '{"source": "universal", "url": "https://example.com"}'带解析的Google搜索:
bash
curl -X POST 'https://realtime.oxylabs.io/v1/queries' \
-u "$OXY_WSA_USERNAME:$OXY_WSA_PASSWORD" \
-H 'Content-Type: application/json' \
-d '{"source": "google_search", "query": "best laptops", "parse": true}'通过ASIN抓取Amazon产品:
bash
curl -X POST 'https://realtime.oxylabs.io/v1/queries' \
-u "$OXY_WSA_USERNAME:$OXY_WSA_PASSWORD" \
-H 'Content-Type: application/json' \
-d '{"source": "amazon_product", "query": "B07FZ8S74R", "parse": true}'Choosing the Right Source
选择合适的Source
- Use specific sources when available (,
amazon_product) - better parsing and reliabilitygoogle_search - Use for unsupported sites - works with any URL
universal - Enable for structured JSON output on supported sources
parse: true
- 优先使用特定source(如、
amazon_product)——解析效果更好,可靠性更高google_search - 对于不支持的站点,使用——适用于任意URL
universal - 在支持的source中启用——获取结构化JSON输出
parse: true
Response Structure
响应结构
json
{
"results": [{
"content": "...",
"status_code": 200,
"url": "https://..."
}]
}With , contains structured data (title, price, reviews, etc.) instead of raw HTML.
parse: truecontentjson
{
"results": [{
"content": "...",
"status_code": 200,
"url": "https://..."
}]
}当启用时,字段将包含结构化数据(标题、价格、评论等),而非原始HTML。
parse: truecontentAvailable Sources
可用Source
For the complete list of 40+ supported sources organized by category, see sources.md.
有关按类别划分的40+支持source完整列表,请查看sources.md。
More Examples
更多示例
For detailed request/response examples including geo-location, JavaScript rendering, and custom headers, see examples.md.
有关包含地理定位、JavaScript渲染和自定义请求头的详细请求/响应示例,请查看examples.md。
Error Handling
错误处理
| Code | Meaning |
|---|---|
| 200 | Success |
| 400 | Invalid parameters |
| 401 | Authentication failed |
| 403 | Access denied |
| 429 | Rate limit exceeded |
| 状态码 | 含义 |
|---|---|
| 200 | 成功 |
| 400 | 参数无效 |
| 401 | 认证失败 |
| 403 | 访问被拒绝 |
| 429 | 超出速率限制 |
Key Guidelines
核心指南
- Always set for supported sources to get structured data
parse: true - Use ZIP codes for US e-commerce geo-location (e.g., )
"90210" - Use country/state format for search engines (e.g., )
"California,United States" - Add for JavaScript-heavy pages
render: "html" - Use only to disable automatic forced rendering for force-rendered pages; set client timeouts near 180 seconds for rendered Realtime or Proxy Endpoint requests
render: "" - Add when scraping image URLs, then decode
content_encoding: "base64"before saving the fileresults[0].content
- 对于支持的source,始终设置以获取结构化数据
parse: true - 针对美国电商地理定位,使用邮政编码(例如:)
"90210" - 针对搜索引擎,使用国家/州格式(例如:)
"California,United States" - 对于JavaScript密集型页面,添加
render: "html" - 仅在强制渲染页面中需要禁用自动强制渲染时,设置;对于渲染型即时请求或代理端点请求,将客户端超时设置为180秒左右
render: "" - 抓取图片URL时,添加,保存文件前需解码
content_encoding: "base64"results[0].content