Web Tool
网页浏览工具用于访问和提取网页内容。
功能
- 网页抓取
- 内容提取
- 表单交互
- JavaScript 执行
使用方法
typescript
import { web } from 'openclaw/tools'
// 获取页面内容
const page = await web.fetch({
url: 'https://example.com',
options: {
waitUntil: 'networkidle',
timeout: 30000
}
})
// 提取特定内容
const data = await web.extract({
page,
selector: '.article-content',
format: 'markdown'
})
// 提交表单
await web.submit({
url: 'https://example.com/form',
form: {
name: 'John',
email: 'john@example.com'
}
})配置
json
{
"web": {
"timeout": 60000,
"userAgent": "OpenClaw/1.0",
"respectRobotsTxt": true,
"rateLimit": {
"requestsPerSecond": 2
}
}
}注意事项
- 遵守网站 robots.txt
- 控制请求频率
- 尊重版权和隐私政策