CrawlForge
基础工具1 credit

extract_text

通过智能解析从 HTML 中提取干净、易读的文本。在保留主要文本内容的同时,自动移除脚本、样式和样板内容。

使用场景

为 LLM 提取文章

提取干净的文章文本,用于摘要、分析或 AI 处理

内容分析

获取纯文本用于词数统计、可读性分析或情感检测

用于摘要的干净文本

在传给摘要模型之前移除 HTML 噪声

移除样板内容

移除广告、导航等非内容元素

Endpoint

POST/api/v1/tools/extract_text
Auth Required
Free 计划 2 req/s
1 credit

Parameters

注意: 你必须提供 html 或 url 之一。如果两者都提供,则以 html 为准。
NameTypeRequiredDefaultDescription
html
stringOptional-
要从中提取文本的 HTML 内容(html 与 url 二选一)
Example: <html><body><h1>Hello World</h1></body></html>
url
stringOptional-
要抓取并从中提取文本的 URL(html 与 url 二选一)
Example: https://example.com/article
selector
stringOptional-
用于定位特定元素的 CSS 选择器(默认:整个页面)
Example: article, .content, #main
clean
booleanOptionaltrue
移除多余空白并规范化格式
Example: true
preserve_links
booleanOptionalfalse
在提取的文本中包含链接及其 URL
Example: false
preserve_formatting
booleanOptionalfalse
保留基本的 HTML 格式(段落、换行)
Example: false
max_length
numberOptional-
提取文本的最大长度(超出将以 ... 截断)
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,与内容大小或选择器复杂度无关。

相关工具

fetch_url
在提取文本前抓取 HTML 内容(1 credit)
scrape_structured
使用自定义选择器提取结构化数据(2 credits)
content_analysis
分析提取文本的情感和主题(4 credits)
准备好提取干净文本了吗?免费注册,获取 1,000 credits 开始使用。