创建提取任务
POST
/302/crawler/task创建网页爬取任务
价格:根据调用的模型收费
请求参数
Header 参数
Authorization
string
必需
302.AI API Key
示例值:
Bearer {{YOUR_API_KEY}}
Model
string
默认gpt-4o
示例值:
gpt-4o-mini
Body 参数application/json
urls
array[string]
爬取的链接列表
需要爬取的网页链接
target
string
任务描述
详细的任务描述有利于爬取数据的准确性
schema
object
需要获取的数据结构
需要返回的数据格式结构
recursiveConfig
object
爬虫设置
基本的爬虫设置
matchType
string
匹配模式
自动为直接获取信息,手动则是先获取对应爬虫代码
searchModel
string
检索模式
默认只爬取传入链接,深度为自动检索相关链接
outputMd
boolean
MD输出
是否输出网页提取的markdown内容
maxDepth
integer
最大深度
开启深度模式的深度限制
maxUrls
integer
最大链接
最大检索链接限制
proxyConfig
object
代理设置
打开网页时候使用的代理服务
proxyUrl
string
可选
proxyUsername
string
可选
proxyPassword
string
可选
browserConfig
object
浏览器设置
浏览器详细设置
headless
boolean
可选
browserType
string
可选
viewportWidth
integer
可选
viewportHeight
integer
可选
userAgent
string
可选
cacheEnabled
boolean
可选
jsEnabled
boolean
可选
lightMode
boolean
可选
textMode
boolean
可选
cookies
array[string]
可选
headers
object
可选
示例1
{
"urls": [
"https://news.302.ai"
],
"target": "AI大模型及详情介绍",
"schema": {
"topic": {
"type": "string",
"description": "文章主题"
},
"view": {
"type": "number",
"description": "文章浏览量"
},
"detail": {
"type": "string",
"description": "文章详情概要"
},
"keywords": {
"type": "array",
"description": "文章关键词, 最多5个",
"items": {
"type": "string"
}
},
"hot": {
"type": "boolean",
"description": "是否为热门文章, 浏览量超过10"
}
},
"recursiveConfig": {
"matchType": "auto",
"searchModel": "default",
"outputMd": true,
"maxDepth": 1,
"maxUrls": 1
},
"proxyConfig": {
"proxyUrl": "",
"proxyUsername": "",
"proxyPassword": ""
},
"browserConfig": {
"headless": true,
"browserType": "chromium",
"viewportWidth": 1920,
"viewportHeight": 1080,
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)",
"cacheEnabled": false,
"jsEnabled": false,
"lightMode": false,
"textMode": false,
"cookies": [],
"headers": {
"Accept-Language": "zh-CN"
}
}
}
示例代码
返回响应
成功(201)
HTTP 状态码: 201
内容格式: JSONapplication/json
数据结构
taskId
string
任务ID
status
string
任务状态
message
string
任务描述
示例
{
"taskId": "48c4efe2-f890-4b3a-a595-54fb2ad2623a",
"status": "pending",
"message": "Task started successfully"
}
最后修改时间: 21 天前