内容读取器 API
获取网页信息,结构化返回网页内容。
请求路径
POST https://usearch.xiaosuai.com/api/search/read
请求
请求头(Headers)
| 参数 | 类型 | 描述 |
|---|---|---|
Authorization |
String | 值: {API key} 将API key替换为你真实的API key |
Content-Type |
String | 值: application/json |
请求参数(Body)
| 参数 | 是否必填 | 类型 | 描述 |
|---|---|---|---|
url |
必填 | String | 读取目标URL地址 |
formats |
选填 | List<String> | 内容格式,可选值:HTMLTEXTMARKDOWNSCREENSHOT(仅quality模式下支持)入参时必须填其中一个值,不传参默认 TEXT |
mode |
选填 | String | 爬取类型,可选值:quality:质量模式,使用动态渲染爬取方式fast:快速模式,静态页面爬取方式 (不填时默认值)auto:智能模式,自动根据url选择fast或quality注意:默认匹配为 fast |
timeout |
选填 | Int | 爬取超时时间,单位:ms,默认值:30000注意:控制api connect的时间,非请求api的耗时时间。 |
imageDownloadEnable |
选填 | Bool | 图片转换开关(转成base64的编码格式),默认值为 false。当值为true且formats是HTML/MARKDOWN时,返回的网页数据中,图片链接转换为base64格式。注意: •开启图片转换,解析到网页中的图片,会产生额外费用 •当url网页内容是pdf时,此功能失效。pdf中所包含的图片返回效果取决于pdfExtractEnable参数取值。 |
imageInContent |
选填 | Bool | 该参数配合imageDownloadEnable使用,默认值为 true。结果返回转base64之后的图片,内嵌在网页正文中。若该值为 false,则返回值中,增加出参image_base64_list。网页正文仅内嵌图片链接,图片转base64之后的编码,在image_base64_list列表里依次列出。 |
pdfExtractEnable |
选填 | Bool | 当url网页内容是pdf时,可通过该参数指定是否解析内容(formats=SCREENSHOT不适用),默认为 false。若url不包含pdf内容,则此参数无效。值为 true: 以formats指定格式返回解析后的pdf内容文本。值为 false: 返回pdf文件源码的base64格式。注意:使用PDF内容提取会产生额外费用。 |
pdfImageDownloadEnable |
选填 | Bool | 配合pdfExtractEnable参数使用,仅pdfExtractEnable=true时生效:false(默认值): pdf解析结果仅返回pdf内的文本内容,不返回图片相关的数据。值为 true: pdf解析结果同时返回pdf内的文本内容和图片base64编码数据(在image_list字段中输出)。注意:当pdf图片较大时,会较显著增加返回时间和数据量。 |
enhancedOcr |
选填 | Bool | 增强版pdf提取,提升提取准确率和覆盖率,默认 false。该参数仅在pdfExtractEnable为true时才会生效。注意:OCR识别成功会产生额外费用。 |
fullPage |
选填 | Bool | 配合formats=SCREENSHOT时使用,截图输出范围(默认) 值为 true:返回全页面截图值为 false:返回首屏截图 |
outputQuality |
选填 | Int | 配合formats=SCREENSHOT时使用,截图输出质量,取值:1~100(默认值:100)。数值越大,截图清晰度越高,base64随之越大。 |
返回值
响应正文(Body)
| 字段 | 类型 | 描述 |
|---|---|---|
html |
String | 当formats=HTML时,则显示页面上内容的HTML版本。 |
markdown |
String | 当formats=MARKDOWN时,返回markdown版本。 |
text |
String | 当formats=TEXT时,返回text版本。 |
screenshot |
String | 当formats=SCREENSHOT时,返回页面截图的base64。 |
metadata.title |
String | 网页标题。 |
metadata.description |
String | 网页描述。 |
metadata.keywords |
String | 网页关键字。 |
logo |
String | 网站logo的url。 |
site_name |
String | 网站名称。 |
image_list |
Array | 图片链接列表(去重)。 当url网页内容是pdf时,若pdfExtractEnable= true,返回pdf中所包含的图片的base64格式;若pdfExtractEnable=false,不返回。当url为普通网页(非pdf)时,返回网页中所包含的图片链接(去重),formats= TEXT除外。 |
image_base64_list |
Array | 图片链接列表(去重),仅 当imageInContent= false时单独返回,为图片base64格式,与image_list的图片链接一一对应。当imageInContent= true时,不返回该字段,图片base64格式编码内嵌于返回的网页正文中。 |
pdf_pages |
Int | 目标为PDF时,PDF的页数。 |
internal_links |
Array | 读取目标url内容包含的内链接列表,内链接指链接域名与目标url一致。 |
external_links |
Array | 读取目标url内容包含的外链接列表,外链接指链接域名与目标url不一致。 |
requestId |
String | 请求ID(唯一标识),请在问题反馈时提供,便于问题定位与排查 |
请求示例
curl -i --location --request POST 'https://usearch.xiaosuai.com/api/search/read' \
--header 'Authorization: <YOUR_API_KEY>' \
--header 'Content-Type: application/json' \
--data-raw '{
"url": "https://example.com",
"formats": [
"TEXT"
],
"mode":"auto"
}'import requests
response = requests.post(
"https://usearch.xiaosuai.com/api/search/read",
headers={
"Authorization": "<YOUR_API_KEY>",
"Content-Type": "application/json"
},
json={
"url": "https://example.com",
"formats": [
"TEXT"
],
"mode": "auto"
}
)
data = response.json()
print(data)响应示例
{
"markdown": "导航\n\n请求结构\n\n最近更新时间:2025.04.23 12:06:55首次发布时间:2021.02.25 21:02:47\n\n火山引擎的OpenAPI的请求结构如下:\n\n服务地址(Endpoint)用于访问火山引擎的云服务,通常是一个URL,客户端可以通过该地址与服务进行通信。 \n火山引擎服务地址的标准形式为:\n\nRegional服务 (区域化部署) Global服务(中心化部署)\n\n \n \n {service}.{region}.volcengineapi.com\n\n例如:云服务器的Service为:ecs,其在\n\n \n \n cn-beijing-autodriving\n\nRegion的服务地址为:\n\necs.cn-beijing-autodriving.volcengineapi.com\n\n \n \n {service}.volcengineapi.com\n\n例如:访问控制的Service为:iam,作为Global服务,其服务地址为:iam.volcengineapi.com\n\n注意\n\n * 当Service中存在下划线( _ )符号时,Endpoint需转为中划线( - )符号。存在大写字母时需转成小写。\n * 存在部分云产品暂未适配标准Endpoint,请前往您所使用的云产品-API参考或开发指南中查看详情。\n\n推荐使用安全性更高的 HTTPS方式发送请求。\n\n请求方法详见各个接口具体的需求。在火山引擎中的OpenAPI大多数支持GET或POST请求。\n\n火山引擎的OpenAPI请求包含两类参数:公共请求参数和接口请求参数。其中公共请求参数在每个请求中都必须包含。接口请求参数需参考各个服务的接口文档。\n\n请求及返回结果使用UTF-8的字符集进行编码。\n\n售后在线咨询\n\n",
"logo": "https://portal.volccdn.com/obj/volcfe/misc/favicon.png",
"site_name": "API签名调用指南",
"image_list": [],
"metadata": {
"title": "请求结构--API签名调用指南-火山引擎",
"description": "火山引擎官方文档中心,产品文档、快速入门、用户指南等内容,你关心的都在这里,包含火山引擎主要产品的使用手册、API或SDK手册、常见问题等必备资料,我们会不断优化,为用户带来更好的使用体验",
"keywords": "API签名调用指南"
},
"internal_links": [],
"external_links": []
}附:状态码说明
| HTTP status code | Error code | Message | Possible cause |
|---|---|---|---|
| 400 | 1400 | Failed to fetch content | 请求失败没结果或爬取状态码非200 |
| 400 | 1401 | Screenshot format is not supported with this crawler type. | 当前模式不支持返回网页截图 |
| 400 | 1402 | PDF needs formats: HTML OR MARKDOWN OR TEXT | 当前模式(如:SCREENSHOT)不支持PDF解析 |
| 400 | 1403 | URL is required / Invalid URL | 请求体 URL 格式错误、缺失或不完整 |
| 400 | 1404 | DNS resolution failed for hostname: {domain}. Please check if the domain is valid and accessible. | 请求体 URL 域名解析失败,如:死链、域名错误等 |
| 400 | 1461 | Anti-crawling protection triggered by target site | 目标网站反爬,不支持读取 |
| 400 | 2112 | No available endpoint | 请求端点错误(或与AK不对应) |
| 400 | Bad Request | 非法请求,如:请求语法/格式非法,请求头格式错误等 | |
| 400 | 400 | unSupported operation | endpoint不支持对应产品 |
| 401 | 401 | You are not authorized to access this resource. | AK 无效 |
| 403 | 403 | ip not in white list | console 设置了 ip 白名单,请求 ip 不在白名单中 |
| 404 | Not Found | 接口请求url错误或不存在 | |
| 405 | 405 | Method Not Allowed | http请求方式错误(如:post请求错用get) |
| 415 | 415 | Unsupported Media Type | 请求头Content-Type错误 |
| 422 | 422 | {"detail":[{"type":"string_type","loc":["body","url"],"msg":"Input should be a valid string","input":null}]} | 请求体缺少必要参数,如url |
| 422 | 422 | {"detail":[{"type":"enum","loc":["body","formats",0],"msg":"Input should be 'HTML', 'MARKDOWN', 'TEXT' or 'SCREENSHOT'","input":"MARKDOWNS","ctx":{"expected":"'HTML', 'MARKDOWN', 'TEXT' or 'SCREENSHOT'"}}]} | formats为非法枚举值 |
| 429 | 429 | The request frequency has exceeded the client’s configured limit. Please contact customer support for adjustments. | qps超限 |
| 500 | ServerError | Internal Server Error | 服务内部异常 |
| 502 | ServerError | Bad Gateway | 错误网关 |
| 503 | 503 | Service Unavailable | 服务不可用 |
| 504 | timeout | Gateway Timeout | 网关超时 |