MarkUDown
Create Schema API — MarkUDown AI 提取 Schema 生成文档
POST
/api/create-schema生成 Schema(Create Schema)
用自然语言描述你需要的数据,即可获得由 LLM 生成的提取配置建议:字段及其类型、提取范围,以及 URL 的关键词/路径过滤条件。请求是同步的。
| 参数 | 类型 | 必填 | 默认值 | 描述 |
|---|---|---|---|---|
| query | string | 必填 | — | 用自然语言描述你需要的数据,可附上网站 URL。 |
请求
curl -X POST https://api.scrapetechnology.com/api/create-schema \
-H "X-API-KEY: your-api-key" \
-H "Content-Type: application/json" \
-d '{"query": "title, price and star rating of every book on https://books.toscrape.com"}'响应
{
"url": "https://books.toscrape.com",
"extraction_scope": "list_page",
"extraction_target": null,
"title": "string",
"price": "float",
"rating": "string",
"allowed_words": ["catalogue", "book"],
"blocked_words": ["login", "basket"],
"allowed_patterns": ["/catalogue/"],
"blocked_patterns": []
}Python — pip install markudown
from markudown import MarkUDown
md = MarkUDown(api_key="your-api-key")
schema = md.create_schema("title, price and star rating of every book on https://books.toscrape.com")
print(schema)Node.js — npm install markudown-sdk
import { MarkUDown } from "markudown-sdk";
const md = new MarkUDown({ apiKey: "your-api-key" });
const schema = await md.createSchema("title, price and star rating of every book on https://books.toscrape.com");
console.log(schema);响应是一个扁平的 JSON 对象:除 url、extraction_scope、extraction_target 和四个过滤列表之外,每个键都是一个字段名,值为其类型。要用于 Extract,请把每个字段转换为 {"name": …, "type": …, "active": true}。extraction_scope 取值为 whole_site、category、single_page、search_query、list_page 或 unknown。结果由 LLM 生成,请先检查。
费用: 不消耗积分;计入速率限制。