获取可用城市代理
在提交批量任务时,可以通过 regionCode 参数指定爬虫使用的代理 IP 城市/省份。这样可以确保爬虫从指定地区发起请求,获取地域化的数据结果。
接口说明
接口地址: GET /api/business/eip-edge/ports/city-info
接口描述: 查询所有可用的代理端口及其对应的城市信息,用于获取 regionCode 参数的可选值
需要认证: 否(公开接口)
请求参数
Query 参数:
| 参数名 | 类型 | 必需 | 默认值 | 描述 |
|---|---|---|---|---|
| deduplicate | Boolean | 否 | false | 是否按区域代码去重(true-每个城市只返回一个端口,false-返回所有端口) |
响应结果
成功响应:
{
"success": true,
"code": 200,
"message": "操作成功",
"data": [
{
"port": 10001,
"province": "河南省",
"city": "郑州",
"regionCode": ["410100"],
"outIp": "120.217.21.77",
"active": true
},
{
"port": 10002,
"province": "陕西省",
"city": "西安",
"regionCode": ["610100"],
"outIp": "113.200.229.25",
"active": true
}
]
}
响应字段说明:
| 字段名 | 类型 | 描述 |
|---|---|---|
| port | Integer | 代理端口号 |
| province | String | 省份名称 |
| city | String | 城市名称 |
| regionCode | Array<String> | 区域代码数组(行政区划代码),用于提交任务时的 regionCode 参数。当前提交任务仅支持指定 1 个 regionCode(数组长度必须为 1) |
| outIp | String | 代理出口 IP 地址 |
| active | Boolean | 端口是否活跃 |
使用流程
# 步骤1: 获取可用城市代理
curl -X GET "https://business-api.molizhishu.com/api/business/eip-edge/ports/city-info?deduplicate=true"
# 步骤2: 从响应中提取 regionCode
# 例如获取到:郑州市-410100、西安市-610100
# 步骤3: 提交任务时指定 regionCode
curl -X POST "https://business-api.molizhishu.com/api/business/monitor/task/batch/shared" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"prompts": ["人工智能发展趋势"],
"platforms": [{"platform": "deepseek", "mode": "search"}],
"regionCode": ["410100"]
}'
注意事项
- regionCode 格式: 必须是有效的行政区划代码,可以通过本接口获取
- 单城市限制: 当前仅支持指定 1 个 regionCode(数组长度必须为 1)
- 去重参数: 建议使用
deduplicate=true,避免返回同一城市的多个端口,简化选择 - 未指定时的行为: 如果不传
regionCode参数,爬虫会使用默认代理策略 - 代码有效性: regionCode 必须是当前可用的端口对应的城市代码,否则可能导致任务执行失败