使用场景
为 LLM 提取文章
提取干净的文章文本,用于摘要、分析或 AI 处理
内容分析
获取纯文本用于词数统计、可读性分析或情感检测
用于摘要的干净文本
在传给摘要模型之前移除 HTML 噪声
移除样板内容
移除广告、导航等非内容元素
Endpoint
POST
/api/v1/tools/extract_textAuth Required
Free 计划 2 req/s
1 credit
Parameters
注意: 你必须提供
html 或 url 之一。如果两者都提供,则以 html 为准。| Name | Type | Required | Default | Description |
|---|---|---|---|---|
html | string | Optional | - | 要从中提取文本的 HTML 内容(html 与 url 二选一) Example: <html><body><h1>Hello World</h1></body></html> |
url | string | Optional | - | 要抓取并从中提取文本的 URL(html 与 url 二选一) Example: https://example.com/article |
selector | string | Optional | - | 用于定位特定元素的 CSS 选择器(默认:整个页面) Example: article, .content, #main |
clean | boolean | Optional | true | 移除多余空白并规范化格式 Example: true |
preserve_links | boolean | Optional | false | 在提取的文本中包含链接及其 URL Example: false |
preserve_formatting | boolean | Optional | false | 保留基本的 HTML 格式(段落、换行) Example: false |
max_length | number | Optional | - | 提取文本的最大长度(超出将以 ... 截断) Example: 5000 |
请求示例
cURL - 从 URL 提取
terminalBash
TypeScript - 从 HTML 提取
extractText.tsTypescript
Python - 使用选择器提取
extract_text.pyPython
响应示例
200 OK180ms
{ "success": true, "data": { "text": "Article Title\n\nThis is the main content of the article. It contains useful information that has been extracted from the HTML.\n\nLinks:\nRelated Article (/related)", "metadata": { "title": "Article Title - Example Site", "description": "Meta description of the article", "word_count": 248, "character_count": 1432, "selector_used": "article", "links_preserved": true, "formatting_preserved": false } }, "credits_used": 1, "credits_remaining": 999, "processing_time": 180}Field Descriptions
data.text提取的纯文本内容data.metadata.word_count提取文本中的总词数data.metadata.character_count字符总数data.metadata.selector_used实际应用的 CSS 选择器credits_used本次请求扣除的 credits(每次提取 1 个)错误处理
缺少输入(400 Bad Request)
html 和 url 都未提供。你必须至少提供其中一个。
无效选择器(400 Bad Request)
CSS 选择器无效或未匹配到任何元素。请检查选择器语法。
URL 抓取失败(500 Internal Server Error)
抓取 URL 失败。请检查该 URL 可访问并返回 HTML。
credit 费用
1 credit
每次请求 1 credit
每次文本提取花费 1 credit,与内容大小或选择器复杂度无关。
相关工具
准备好提取干净文本了吗?免费注册,获取 1,000 credits 开始使用。