Install
openclaw skills install scraperapi-global-access全球多国IP访问网站,支持25+国家代理、JS渲染、用户行为模拟、性能监控、断点续传。适用于广告验证、竞品分析、SEO监控、GA测试、CDN效果对比。
openclaw skills install scraperapi-global-access通过 ScraperAPI 实现全球多国 IP 访问网站,支持 JS 渲染、用户行为模拟、性能监控。
| 场景 | 说明 |
|---|---|
| 广告验证 | 验证广告在不同地区的投放效果 |
| 竞品分析 | 监控竞品网站在全球的可用性和性能 |
| SEO 监控 | 检查网站在不同地区的 SEO 表现 |
| GA 测试 | 验证 Google Analytics 是否正确触发 |
| CDN 对比 | 对比不同 CDN 在全球的性能 |
| 可用性监控 | 定期检查网站在全球的可访问性 |
npm install axios
访问 ScraperAPI Dashboard 获取 API Key。
在工作目录创建 .env 文件:
SCRAPER_API_KEY=your_api_key_here
node scripts/single_visit.js --url https://example.com --country us
node scripts/global_coverage.js --url https://example.com
node scripts/user_journey.js --url https://example.com --countries us,uk,jp
node scripts/performance_monitor.js --url https://example.com --interval 3600
single_visit.js - 单次访问访问指定 URL,使用指定国家的代理。
参数:
--url - 目标网址(必填)--country - 国家代码(默认:us)--render - 是否渲染 JS(默认:true)--output - 输出文件路径(可选)示例:
node scripts/single_visit.js --url https://faceswap.cool --country jp --render true
global_coverage.js - 全球覆盖使用 25 个国家的 IP 访问目标网站。
参数:
--url - 目标网址(必填)--render - 是否渲染 JS(默认:true)--interval - 访问间隔(秒,默认:5)--output-dir - 输出目录(默认:./reports)示例:
node scripts/global_coverage.js --url https://example.com --interval 3
输出文件:
global_report.json - 完整 JSON 报告global_results.csv - 访问记录 CSVperformance_data.csv - 性能数据 CSVuser_journey.js - 用户旅程模拟模拟真实用户浏览多个页面。
参数:
--url - 网站根 URL(必填)--pages - 页面路径列表(逗号分隔,默认:/,/pricing,/about)--countries - 国家代码列表(逗号分隔,默认:us,uk,jp)--wait-min - 最小停留时间(秒,默认:3)--wait-max - 最大停留时间(秒,默认:6)示例:
node scripts/user_journey.js \
--url https://example.com \
--pages /,/tools/face-swap,/pricing \
--countries us,uk,de,jp \
--wait-min 3 \
--wait-max 8
performance_monitor.js - 性能监控定期访问网站,记录性能数据。
参数:
--url - 目标网址(必填)--interval - 监控间隔(秒,默认:3600)--countries - 监控的国家(逗号分隔,默认:us,uk,de,jp,sg)--duration - 运行时长(秒,0=无限,默认:0)示例:
# 每小时监控一次,持续 24 小时
node scripts/performance_monitor.js \
--url https://example.com \
--interval 3600 \
--duration 86400
| 地区 | 国家代码 |
|---|---|
| 北美 | us, ca, mx |
| 南美 | br, ar, cl |
| 欧洲 | gb, de, fr, it, es, nl, se, pl |
| 亚洲 | jp, kr, sg, in, id, th |
| 大洋洲 | au, nz |
| 非洲 | za, eg, ng |
完整列表见 ScraperAPI 文档。
创建 config.json:
{
"scraperapi": {
"apiKey": "your_api_key",
"defaultRender": true,
"timeout": 90000,
"retries": 3
},
"monitoring": {
"interval": 3600,
"countries": ["us", "uk", "de", "jp", "sg"],
"alertThreshold": 30000
},
"output": {
"format": "json",
"directory": "./reports",
"keepHistory": true
}
}
| 变量名 | 说明 | 默认值 |
|---|---|---|
SCRAPER_API_KEY | ScraperAPI 密钥 | 必填 |
SCRAPER_TIMEOUT | 请求超时(毫秒) | 90000 |
SCRAPER_RENDER | 默认是否渲染 JS | true |
OUTPUT_DIR | 输出目录 | ./reports |
所有脚本支持断点续传,中断后重新运行会自动继续:
# 第一次运行(中断)
node scripts/global_coverage.js --url https://example.com
# 重新运行(自动跳过已完成的国家)
node scripts/global_coverage.js --url https://example.com
进度保存在 progress.json,可手动删除以重新开始。
{
"generatedAt": "2026-03-20T05:00:00.000Z",
"summary": {
"totalVisits": 37,
"successfulVisits": 35,
"failedVisits": 2,
"successRate": "94.6%"
},
"globalCoverage": {
"countries": 25,
"regions": 6
},
"results": [
{
"success": true,
"country": "美国",
"countryCode": "us",
"region": "北美",
"page": "/",
"title": "Example Site",
"status": 200,
"size": 188759,
"responseTime": 38629,
"timestamp": "2026-03-20T04:49:11.106Z"
}
],
"performanceData": [...]
}
Country,Region,Page,Status,ResponseTime,Title,Timestamp
美国,北美,/,Success,38629,"Example Site",2026-03-20T04:49:11.106Z
// ✅ 推荐:随机间隔
const waitTime = Math.random() * 3000 + 3000; // 3-6秒
// ❌ 不推荐:固定间隔
const waitTime = 2000; // 太规律
// ✅ 需要触发 GA 时开启
render: true
// ✅ 只抓取 HTML 时关闭(更快)
render: false
try {
const result = await visitPage(country, url);
saveProgress(result);
} catch (error) {
console.error('访问失败:', error.message);
// 继续下一个,不中断整个任务
}
session_number 参数复用会话原因:请求过快,超出配额。
解决:
--interval 参数原因:目标网站在该地区不可用,或 ScraperAPI 代理问题。
解决:
原因:
解决:
编辑 scripts/countries.json:
{
"custom": [
{ "country": "美国", "code": "us", "region": "北美" },
{ "country": "中国", "code": "cn", "region": "亚洲" }
]
}
// 每天早上 9 点运行
{
"name": "全球访问监控",
"schedule": {
"kind": "cron",
"expr": "0 9 * * *",
"tz": "Asia/Shanghai"
},
"payload": {
"kind": "agentTurn",
"message": "运行 scraperapi-global-access skill,监控 https://example.com"
},
"sessionTarget": "isolated"
}
使用生成的 CSV 文件:
# 导入到 Excel/Google Sheets
# 或使用 Python 生成图表
python scripts/visualize.py performance_data.csv
访问单个页面。
参数:
country - 国家对象 { country, code, region }url - 目标 URLoptions - 配置选项
render - 是否渲染 JS(默认:true)timeout - 超时时间(默认:90000)sessionNumber - 会话编号(可选)返回:
{
success: true,
country: "美国",
countryCode: "us",
region: "北美",
page: "/",
title: "Example",
status: 200,
size: 188759,
responseTime: 38629,
timestamp: "2026-03-20T04:49:11.106Z"
}
MIT License
欢迎提交 Issue 和 Pull Request!