fetch_to_file
Retrieve web content from a URL and save it to a specified file, with options for raw HTML, cleaned HTML, or Markdown conversion.
Instructions
获取网页内容并保存到文件。 - 如果是 HTML, 则根据 return_content 返回合适的内容, - 如果不是 HTML,但是是 Text 或 Json 内容,则直接保存其内容。 - 如果是其它类型的内容,则返回错误信息。
Args:
url (str): 要获取的网页 URL。
file_path (str): 要保存到的文件路径,必须是绝对路径。
return_content ("raw" | "basic_clean" | "strict_clean" | "markdown", optional): 默认为 "markdown",用于控制返回 html 内容的方式,
- 如果为 raw,返回原始 HTML 内容。
- 如果为 basic_clean,返回过滤后的 HTML 内容,过滤掉所有不会显示的标签,如 script, style 等。
- 如果为 strict_clean,返回过滤后的 HTML 内容,过滤掉所有不会显示的标签,如 script, style 等,并且会删除大部分无用的 HTML 属性。
- 如果为 markdown,HTML 转换为 Markdown 后返回。
Returns:
- 成功时返回文件保存路径
- 如果路径不安全则返回错误信息
Input Schema
Name | Required | Description | Default |
---|---|---|---|
file_path | Yes | ||
return_content | No | markdown | |
url | Yes |
Input Schema (JSON Schema)
{
"properties": {
"file_path": {
"title": "File Path",
"type": "string"
},
"return_content": {
"default": "markdown",
"enum": [
"raw",
"basic_clean",
"strict_clean",
"markdown"
],
"title": "Return Content",
"type": "string"
},
"url": {
"title": "Url",
"type": "string"
}
},
"required": [
"url",
"file_path"
],
"title": "fetch_to_fileArguments",
"type": "object"
}