🎭 Playwright HTTP Service

Status: ✓ Running

使用 Playwright 进行网页抓取的 HTTP API 服务,支持 JS 渲染和反爬虫特性。

📡 API Endpoints

GET /

当前页面 - API 使用文档

POST /fetch

抓取网页内容(支持 JS 渲染)

📋 请求参数

参数 类型 必填 默认值 说明
url string - 要抓取的网页 URL
wait_until string 可选 networkidle 等待策略:load, domcontentloaded, networkidle
timeout integer 可选 30000 超时时间(毫秒),范围:1000 - 120000

📤 返回结果

字段 类型 说明
content string 渲染后的完整 HTML 内容
url string 最终 URL(处理重定向后)
title string 页面标题

🔐 身份验证

重要提示:

如何使用:在请求中添加 -H "X-API-Key: your-api-key-here"

请联系服务管理员获取 API key。

💡 使用示例

cURL(含 API key)

curl -X POST https://playwright.yibozhang.me/fetch \
  -H "X-API-Key: your-api-key-here" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com",
    "wait_until": "networkidle",
    "timeout": 30000
  }'

Python(含 API key)

import requests

response = requests.post(
    "https://playwright.yibozhang.me/fetch",
    headers={
        "X-API-Key": "your-api-key-here",
        "Content-Type": "application/json"
    },
    json={
        "url": "https://example.com",
        "wait_until": "networkidle",
        "timeout": 30000
    }
)
result = response.json()
print(f"Title: {result['title']}")
print(f"Content length: {len(result['content'])}")

注意:本地访问可以省略 X-API-Key 请求头。

🛡️ 反爬虫特性

⚙️ wait_until 参数说明


Playwright HTTP Service | Powered by FastAPI + Playwright