使用Tavily提取API从指定URL获取网页内容,返回干净的markdown或文本格式。适用于有特定URL且需要内容但不想写代码的场景。
提取 STelly , 从特定 URL 中提取干净的内容是一项面向实际任务的技能,主要用于理想的状态是您知道您想要的内容来自哪个页面;Prerequists.;
使用时应结合输入条件选择合适的执行方式,核对必要参数、依赖环境与输出内容,并按原始要求处理异常情况。从功能定位来看,该技能强调把分散的操作要求整理成清晰、可复用的处理流程,使用户能够围绕既定目标快速准备输入、选择执行方式并获得结构化结果。实际使用前应先确认任务范围、数据来源、运行环境、必要权限和关键参数,再依据技能说明逐步执行;若输入条件不完整,应先补齐信息或采用保守配置,避免因错误假设导致结果偏离需求。
执行过程中需要关注工具调用是否成功、接口或依赖是否可用、输出格式是否符合预期,并对异常提示、缺失字段和边界情况进行处理;涉及批量任务时,还应保存进度,避免中断后重复操作。该技能适合用于一次性任务,也可以接入自动化工作流,与其他技能或上层代理配合完成更完整的业务链路;在组合使用时,应明确每一步的输入输出关系,并避免不同步骤之间出现参数冲突。
从指定 URL 提取干净、结构化的内容。适用于您已明确知道需提取内容的目标页面的场景。
需要 Tavily API Key —— 请前往 https://tavily.com 获取您的密钥
将其添加至 ~/.claude/settings.json 文件中:
{
"env": {
"TAVILY_API_KEY": "tvly-your-api-key-here"
}
}
./scripts/extract.sh ''
示例:
# 单个 URL
./scripts/extract.sh '{"urls": ["https://example.com/article"]}'
# 多个 URL
./scripts/extract.sh '{"urls": ["https://example.com/page1", "https://example.com/page2"]}'
# 指定查询焦点与分块数量
./scripts/extract.sh '{"urls": ["https://example.com/docs"], "query": "authentication API", "chunks_per_source": 3}'
# 针对 JS 渲染页面的高级提取
./scripts/extract.sh '{"urls": ["https://app.example.com"], "extract_depth": "advanced", "timeout": 60}'
curl --request POST
--url https://api.tavily.com/extract
--header "Authorization: Bearer $TAVILY_API_KEY"
--header 'Content-Type: application/json'
--data '{
"urls": ["https://example.com/article"]
}'
curl --request POST
--url https://api.tavily.com/extract
--header "Authorization: Bearer $TAVILY_API_KEY"
--header 'Content-Type: application/json'
--data '{
"urls": [
"https://example.com/ml-healthcare",
"https://example.com/ai-diagnostics"
],
"query": "AI diagnostic tools accuracy",
"chunks_per_source": 3
}'
POST https://api.tavily.com/extract
| Header | Value |
|---|---|
Authorization |
Bearer |
Content-Type |
application/json |
| 字段(Field) | 类型(Type) | 默认值(Default) | 说明(Description) |
|---|---|---|---|
urls |
array | 必需(Required) | 待提取的 URL 列表(最多支持 20 个) |
query |
string | null | 按相关性对内容分块进行重排序 |
chunks_per_source |
integer | 3 | 每个 URL 返回的分块数量(取值范围:1–5;仅当指定 query 时生效) |
extract_depth |
string | "basic" |
basic 或 advanced(适用于 JavaScript 渲染页面) |
format |
string | "markdown" |
markdown 或 text |
include_images |
boolean | false | 是否包含图片 URL |
timeout |
float | 因页面而异 | 最大等待时间(单位:秒,取值范围:1–60) |
{
"results": [
{
"url": "https://example.com/article",
"raw_content": "# Article TitlennContent..."
}
],
"failed_results": [],
"response_time": 2.3
}
| 深度(Depth) | 适用场景(When to Use) |
|---|---|
basic |
纯文本提取,速度快 |
advanced |
动态渲染页面、JavaScript 页面、表格及结构化数据 |
curl --request POST
--url https://api.tavily.com/extract
--header "Authorization: Bearer $TAVILY_API_KEY"
--header 'Content-Type: application/json'
--data '{
"urls": ["https://docs.python.org/3/tutorial/classes.html"],
"extract_depth": "basic"
}'
curl --request POST
--url https://api.tavily.com/extract
--header "Authorization: Bearer $TAVILY_API_KEY"
--header 'Content-Type: application/json'
--data '{
"urls": [
"https://example.com/react-hooks",
"https://example.com/react-state"
],
"query": "useState and useEffect patterns",
"chunks_per_source": 2
}'
curl --request POST
--url https://api.tavily.com/extract
--header "Authorization: Bearer $TAVILY_API_KEY"
--header 'Content-Type: application/json'
--data '{
"urls": ["https://app.example.com/dashboard"],
"extract_depth": "advanced",
"timeout": 60
}'
curl --request POST
--url https://api.tavily.com/extract
--header "Authorization: Bearer $TAVILY_API_KEY"
--header 'Content-Type: application/json'
--data '{
"urls": [
"https://example.com/page1",
"https://example.com/page2",
"https://example.com/page3",
"https://example.com/page4",
"https://example.com/page5"
],
"extract_depth": "basic"
}'
query 和 chunks_per_source,以仅获取与查询高度相关的内容分块basic 模式,若发现关键内容缺失,再回退至 advanced 模式timeout(最长支持 60 秒)failed_results 字段,定位无法成功提取的 URL相关专题
热门下载
相关下载
精品课程
共6课时 | 54.7万人学习
共89课时 | 134.1万人学习
共49课时 | 82.6万人学习
最新文章