快速回答
如何用 curl 测试美国城市代理?
使用 -x 传入代理:curl -x http://USERNAME-country-us-state-oh-city-cleveland:[email protected]:7777 https://ipinfo.io/json 会打印查询服务看到的出口 IP 和城市。MetroProxies 在 US$0.50/GB(2026 年 10 月)起的每个套餐中都包含城市、州、ZIP 和 ASN 定位,同一用户名在 SOCKS5 端口上同样可用。无需 KYC;支持加密货币。
# city
curl -s --max-time 30 -x http://USERNAME-country-us-state-oh-city-cleveland:[email protected]:7777 https://ipinfo.io/json
# ZIP inside the city (downtown Cleveland)
curl -s --max-time 30 -x http://USERNAME-country-us-state-oh-city-cleveland-zip-44114:[email protected]:7777 https://ipinfo.io/json
# one provider's network (AS20115, Spectrum)
curl -s --max-time 30 -x http://USERNAME-country-us-state-oh-city-cleveland-asn-20115:[email protected]:7777 https://ipinfo.io/json
# sticky: run twice, same IP for up to 10 minutes
curl -s --max-time 30 -x http://USERNAME-country-us-state-oh-city-cleveland-session-cle01-ttl-10:[email protected]:7777 https://api.ipify.org
# SOCKS5 (hostname resolved by the proxy)
curl -s --max-time 30 --socks5-hostname gw.metroproxies.com:7778 -U USERNAME-country-us-state-oh-city-cleveland:PASSWORD https://ipinfo.io/json如何测量一个页面使用了多少流量?
在购买流量之前,先通过代理测量一个真实目标页面,再乘以页面数量和城市数量。curl 会打印它下载内容的大小;加上 --compressed 以便测量浏览器会传输的内容,并记住浏览器还会加载 HTML 指向的图片和脚本。
curl -s -o /dev/null --compressed --max-time 60 \
-x http://USERNAME-country-us-state-oh-city-cleveland:[email protected]:7777 \
-w 'downloaded %{size_download} bytes, headers %{size_header} bytes, time %{time_total}s\n' \
https://YOUR-SITE.example/常见的 curl 错误是什么意思?
407 Proxy Authentication Required: 用户名或密码错误,或密码中含有需要 URL 编码的特殊字符(@→%40)。- 超时(退出码 28): 在
--max-time内没有响应;请重试,或将定位从 ZIP 放宽到城市,或从城市放宽到州。 Could not resolve proxy: 检查网关主机名拼写:gw.metroproxies.com。- 在 curl 中可用,但在你的应用中不可用: 你的应用可能保持连接打开(同一 IP),或对某些主机忽略代理;请与 Python 或 Node.js 示例进行对比。
用量统计包含通过代理发送和接收的所有数据(上传和下载,含请求头)。1 GB = 1,000,000,000 字节。未到达目标即失败的连接尝试不计入用量。
人们还常问关于 curl 的哪些问题?
为什么用 --socks5-hostname 而不是 --socks5?
使用 --socks5-hostname 时,由代理解析目标的主机名,而不是你的机器。两者在端口 7778 上使用同一用户名即可工作。
如何每次获取新 IP?
每次运行 curl 都会打开一个新连接,因此在轮换模式下每次运行通常会获得不同的 IP。仅当你需要保持同一个 IP 时才添加会话 ID。
克利夫兰市中心真的是 ZIP 44114 吗?
44114 覆盖克利夫兰市中心和湖滨的大部分地区。城市其他区域请使用 克利夫兰页面 上列出的 ZIP 区域。