MarkUDown
Agent API — MarkUDown AI 网页浏览智能体 API 文档
POST
/api/agent智能体(Agent)
给智能体一个起始 URL 和一个问题。它会读取页面,询问 LLM 是直接回答还是跟随某个链接,并重复这一过程,直到能够回答或步数用尽。你会得到答案以及它执行的每一步。
| 参数 | 类型 | 必填 | 默认值 | 描述 |
|---|---|---|---|---|
| url | string | 必填 | — | 智能体开始的页面。 |
| prompt | string | 必填 | — | 交给智能体的问题或任务。 |
| max_steps | integer | 可选 | 10 | 智能体最多做出的决策次数(上限 25)。 |
| max_pages | integer | 可选 | 5 | 智能体最多访问的页面数(至少 1,上限 15)。任务开始时扣除 max_pages × 2 个积分。 |
| allow_navigation | boolean | 可选 | true | 允许智能体跟随链接访问其他页面。 |
| timeout | integer | 可选 | 120 | 每个页面的加载超时时间(秒)。 |
| callback_url | string | 可选 | null | 任务完成时接收结果(POST)的 webhook URL。 |
请求
curl -X POST https://api.scrapetechnology.com/api/agent \
-H "X-API-KEY: your-api-key" \
-H "Content-Type: application/json" \
-d '{"url": "https://quotes.toscrape.com/", "prompt": "Which tags appear on the quotes by Albert Einstein on the first two pages?", "max_pages": 3}'响应
// POST returns { "success": true, "id": "abc123", "url": "/api/agent/abc123" }
// Poll GET /api/agent/{id}
{
"success": true,
"id": "abc123",
"status": "completed",
"data": {
"success": true,
"data": {
"url": "https://quotes.toscrape.com/",
"answer": "Einstein's quotes are tagged: change, deep-thoughts, ...",
"steps": [
{
"step": 1,
"url": "https://quotes.toscrape.com/",
"action": "navigate",
"reasoning": "Page 1 read; page 2 is needed.",
"result": "Navigating to: https://quotes.toscrape.com/page/2/"
},
{
"step": 2,
"url": "https://quotes.toscrape.com/page/2/",
"action": "answer",
"reasoning": "Both pages read.",
"result": "Einstein's quotes are tagged: change, deep-thoughts, ..."
}
],
"pages_visited": [
"https://quotes.toscrape.com/",
"https://quotes.toscrape.com/page/2/"
],
"total_steps": 2
},
"processing_time_ms": 21400
}
}Python — pip install markudown
from markudown import MarkUDown
md = MarkUDown(api_key="your-api-key")
job = md.agent(
"https://quotes.toscrape.com/",
"Which tags appear on the quotes by Albert Einstein on the first two pages?",
max_pages=3,
)
print(job["data"]["data"]["answer"])Node.js — npm install markudown-sdk
import { MarkUDown } from "markudown-sdk";
const md = new MarkUDown({ apiKey: "your-api-key" });
const job = await md.agent(
"https://quotes.toscrape.com/",
"Which tags appear on the quotes by Albert Einstein on the first two pages?",
{ maxPages: 3 },
);
console.log(job.data.data.answer);智能体会读取页面(滚动以加载延迟内容)并跟随链接;它不会点击按钮或填写表单。每一步的 action 为 answer、navigate、extract 或 done(出错时为 scrape_failed 或 llm_error)。使用 DELETE /api/agent/{id} 取消运行中的任务。
费用: max_pages × 2 个积分,在任务开始时扣除。