← HermesBee 首页

ScrapeBox API — 代码示例

ScrapeBox 作为本地 REST API 运行:http://localhost:8080。无需 API Key、无云依赖,数据留在本机。以下是 Python 和 Node.js 的开箱即用示例。

先启动 ScrapeBox:运行 start.bat(Windows)或 bash start.sh(Mac/Linux),然后执行示例。

Python — 提取页面文本

import requests

r = requests.get("http://localhost:8080/text",
                 params={"url": "https://example.com"})
print(r.json()["data"])  # 干净的页面文本

Python — 提取链接与表格

import requests

# 页面所有链接
links = requests.get("http://localhost:8080/links",
                     params={"url": "https://example.com"}).json()
for link in links["data"]:
    print(link["text"], "->", link["href"])

# 所有表格(行列表)
tables = requests.get("http://localhost:8080/tables",
                      params={"url": "https://example.com"}).json()
for row in tables["data"][0]:
    print(row)  # row = [cell1, cell2, ...]

Node.js — 提取页面文本

const res = await fetch(
  "http://localhost:8080/text?url=https://example.com"
);
const { data } = await res.json();
console.log(data); // 干净的页面文本

与 AI Agent 集成

ScrapeBox 与 MCP 浏览器工具搭配效果最佳。参见 MCP 抓取指南 了解推荐组合。

© 2026 HermesBee · 购买 ScrapeBox · English · GitHub