# 5 分钟获取欧洲城市 IP

> 快速入门：5 分钟内通过 curl、Python、Node 22 或 SOCKS5 连接到巴黎 IP。1 GB 仅需 US$0.95，无需 KYC，支持加密货币支付。

- URL: https://eurocityproxies.com/zh/guides/quickstart/
- 最后更新: 2026-10-18
- Publisher: EuroCity Proxies (https://eurocityproxies.com)

五个可直接复制粘贴的示例，从一行 curl 到 Node.js，全部针对巴黎的家庭 IP。每个示例都会打印出口 IP 及其城市，方便你确认定位是否生效。

**快速解答 — 如何连接到欧洲城市 IP？**

将请求发送到 **EuroCity Proxies** 网关，并在用户名中指定城市，例如 `USERNAME-country-fr-city-paris`，然后读取 `https://ipinfo.io/json` 查看出口。截至 2026 年 10 月，所有套餐均支持城市定位，1 GB 仅需 US$0.95。城市可用性因情况而异，结账时会显示当前在线的城市。

## 首次请求前需要准备什么？

| 属性 | 值 |
| --- | --- |
| 网关端口 | `gw.eurocityproxies.com` |
| HTTP 和 HTTPS 端口 | `7777` |
| SOCKS5 端口 | `7778` |
| 轮换用户名 | `USERNAME-country-fr-city-paris` |
| 粘性用户名 | `USERNAME-country-fr-city-paris-session-paris1-ttl-10` |
| 检查 URL | `https://ipinfo.io/json`（IP、城市、地区、国家、网络） |
| 协议 | HTTP、HTTPS（CONNECT）和 SOCKS5 |

## 用户名是如何构成的？

用户名承载定位信息：先是你的账户用户名，然后是 `-country-` 加小写 ISO 代码，再接可选段。即使添加了城市，国家段也始终必填。

- `-city-paris`：城市 ID，小写、不含重音符号，用 `_` 代替空格或连字符（`-city-the_hague`）。
- `-asn-<number>`：指定单个网络，例如某宽带运营商；ASN 定位不额外收费（[ASN 指南](https://eurocityproxies.com/zh/targeting/asn/)）。
- `-session-paris1-ttl-10`：名为 `paris1` 的粘性会话，最长持续 10 分钟。ttl 最高可设为 30。

国家代码在用户名中为小写，但在 API 中为大写。某个国家的城市 ID 列表来自 `GET /api/v1/catalog/countries/FR/cities`，详见 [API 文档](https://eurocityproxies.com/docs/api/)。请使用它返回的 ID，不要猜测拼写，例如 `kraków` 或 `münchen`。

## 轮换用户名会在每次请求时更换 IP 吗？

它会在每个新连接时更换 IP，而不是每次请求。每个新连接都会从 IP 池分配一个 IP，通常是不同的 IP；如需每个请求都使用新 IP，请每个连接只发送一个请求（关闭 keep-alive）。

这在代码中很重要。`requests.Session`、`httpx.Client` 或 undici agent 会在请求之间保持隧道打开，因此出口保持不变。若要做到每个请求一个 IP，请为每个请求新建客户端，或发送 `Connection: close`。若要有意让多个请求共用一个 IP，请使用粘性会话，详见 [按城市使用粘性会话](https://eurocityproxies.com/zh/guides/city-sessions/)。

*curl：在巴黎实现轮换、粘性和 SOCKS5 出口*

```bash
# Rotating exit in Paris (HTTP proxy, HTTPS target through CONNECT)
curl -s -x "http://USERNAME-country-fr-city-paris:PASSWORD@gw.eurocityproxies.com:7777" https://ipinfo.io/json

# Sticky exit in Paris: session paris1, up to 10 minutes
curl -s -x "http://USERNAME-country-fr-city-paris-session-paris1-ttl-10:PASSWORD@gw.eurocityproxies.com:7777" https://ipinfo.io/json

# SOCKS5 with socks5h: the proxy resolves the hostname, not your machine
curl -s -x "socks5h://USERNAME-country-fr-city-paris:PASSWORD@gw.eurocityproxies.com:7778" https://ipinfo.io/json

# Gateway alone, without a target site: prints only the exit IP
curl -s -x "http://USERNAME-country-fr-city-paris:PASSWORD@gw.eurocityproxies.com:7777" https://api.ipify.org
```

*Python requests：粘性巴黎出口（Python 3.9 或更新版本）*

```python
# pip install requests
from urllib.parse import quote

import requests

HOST = "gw.eurocityproxies.com"
PORT = 7777
USER = "USERNAME-country-fr-city-paris-session-paris1-ttl-10"
PASSWORD = quote("PASSWORD", safe="")  # encodes @, : and / in the password

proxy = f"http://{USER}:{PASSWORD}@{HOST}:{PORT}"
proxies = {"http": proxy, "https": proxy}

# proxies= on each call wins over HTTP_PROXY / HTTPS_PROXY set on your machine
r = requests.get("https://ipinfo.io/json", proxies=proxies, timeout=30)
r.raise_for_status()
info = r.json()
print(info["ip"], info.get("city"), info.get("country"), info.get("org"))
```

*Python httpx：每个客户端同一 IP，新客户端新 IP*

```python
# pip install httpx
from urllib.parse import quote

import httpx

USER = "USERNAME-country-fr-city-paris"
PASSWORD = quote("PASSWORD", safe="")
PROXY = f"http://{USER}:{PASSWORD}@gw.eurocityproxies.com:7777"

# One client keeps its connection open (keep-alive): the three lines show one IP
with httpx.Client(proxy=PROXY, timeout=30, trust_env=False) as client:
    for _ in range(3):
        print("same client:", client.get("https://ipinfo.io/json").json()["ip"])

# A new client per request opens a new connection: usually a different Paris IP
for _ in range(3):
    with httpx.Client(proxy=PROXY, timeout=30, trust_env=False) as client:
        print("new client: ", client.get("https://ipinfo.io/json").json()["ip"])
```

*Node.js 22 或更新版本，undici ProxyAgent（保存为 paris.mjs）*

```javascript
// npm install undici
import { ProxyAgent, fetch } from "undici";

const user = "USERNAME-country-fr-city-paris-session-paris1-ttl-10";
const password = encodeURIComponent("PASSWORD");
const dispatcher = new ProxyAgent(
  `http://${user}:${password}@gw.eurocityproxies.com:7777`
);

try {
  const res = await fetch("https://ipinfo.io/json", {
    dispatcher,
    signal: AbortSignal.timeout(30000), // stop after 30 s
  });
  const info = await res.json();
  console.log(info.ip, info.city, info.country, info.org);
} finally {
  await dispatcher.close();
}
```

*Python requests 通过 SOCKS5 使用 socks5h*

```python
# pip install "requests[socks]"
from urllib.parse import quote

import requests

HOST = "gw.eurocityproxies.com"
SOCKS_PORT = 7778
USER = "USERNAME-country-fr-city-paris"
PASSWORD = quote("PASSWORD", safe="")

# socks5h: the proxy resolves the hostname, not your machine
proxy = f"socks5h://{USER}:{PASSWORD}@{HOST}:{SOCKS_PORT}"
r = requests.get("https://ipinfo.io/json", proxies={"http": proxy, "https": proxy}, timeout=30)
print(r.json())
```

## 这些示例处理了哪些细节？

这些示例处理了最容易导致首次连接失败的细节：

- **对密码进行编码。** Python 中的 `quote("PASSWORD", safe="")` 和 Node 中的 `encodeURIComponent` 可防止 `@` 或 `:` 等字符破坏代理 URL。
- **本机上的代理变量。** 在 requests 中，`session.proxies` 中设置的值可能被 `HTTPS_PROXY` 覆盖。请在每次调用时传入 `proxies=`，或在会话上设置 `trust_env = False`。
- **始终设置超时。** 每个示例都会在 30 秒后停止，而不是一直挂起。
- **顶层 await 需要模块。** 将 Node 示例保存为 `.mjs`，并使用 Node.js 22 或更新版本运行。
- **使用 socks5h，而非 socks5。** 使用 `socks5://` 时，requests 和 curl 会在你的本机解析主机名。使用 `socks5h://` 时，由代理解析。

## 可以在浏览器中使用 SOCKS5 端口吗？

在浏览器中请改用 HTTP 端口 `7777`。Chromium 代理文档指出，Chrome 不支持 SOCKS5 的任何身份验证方式。在端口 `7778` 上使用用户名和密码将无法工作。

在 iPhone 或 iPad 上，Wi-Fi 设置提供带身份验证的手动 HTTP 代理。对于 Android 模拟器，请使用 `-http-proxy http://USERNAME-country-fr-city-paris:PASSWORD@gw.eurocityproxies.com:7777` 启动。[应用地理测试页面](https://eurocityproxies.com/zh/use-cases/app-geo-testing/) 更详细地介绍了设备。

## 输出应显示什么？

来自 `https://ipinfo.io/json` 的 JSON 应显示 `"country": "FR"`，并且大多数情况下会将 `Paris` 或巴黎地区的一个城镇显示为 `city`。`org` 字段以网络的 ASN 开头，例如某法国宽带运营商。

显示巴黎附近的城镇而非巴黎是正常的：地理位置数据库会将许多家庭 IP 定位到运营商的本地枢纽。[出口城市指南](https://eurocityproxies.com/zh/guides/verify-exit-city/) 介绍了如何比较两个来源，[为什么 IP 显示附近城镇](https://eurocityproxies.com/zh/guides/ip-geolocation-accuracy/) 解释了原因。

> **已做语法检查，未对实时目标运行** 2026 年 10 月 18 日，Python 示例已用 python -I -m py_compile 验证，Node 示例已用 node --check 验证。请将 USERNAME 和 PASSWORD 替换为你控制面板中的值。

## 快速上手常见问题

### 为什么我的请求会因 407 Proxy Authentication Required 而失败？

407 表示代理未接受用户名或密码。请确认用户名以你的账户用户名开头、`-country-` 存在，并且密码中的特殊字符已进行 URL 编码。再从控制面板重新复制这两个值。

### 我请求的是巴黎，为什么拿到的是德国 IP？

通常是用户名中有笔误，比如残留了其他测试留下的 `-country-de`，或者城市 id 根本不存在。请在发起请求前打印用户名。如果 `ipinfo.io` 和另一个来源都显示其他国家，请带着时间和出口 IP 联系支持。

### 巴黎的粘性会话最长能保持多久？

粘性会话会保持同一个 IP 最长 30 分钟（IP 可能提前更换，例如住宅设备离线时）。用 `-ttl-` 以分钟为单位设置时长，例如 `-ttl-10` 或 `-ttl-30`。不要指望会话存活时间超过你设置的 ttl。

### 城市定向需要额外收费吗？

不需要。所有套餐均可按国家/城市定向；美国还支持州和 ZIP 邮编定向；ASN 定向不额外收费。可用城市会有变化。每 GB 价格无论是否选择城市都相同。[价格页面](https://eurocityproxies.com/zh/pricing/) 列出 1 GB 为 US$0.95、10 GB 为 US$8。

### 这个快速上手会消耗多少流量？

非常少：每次请求 `https://ipinfo.io/json` 只传输几 KB，包含请求头和 TLS。用量统计通过代理发送和接收的所有数据（上传和下载，包括标头）。1 GB = 1,000,000,000 字节。在到达目标之前失败的连接尝试不计入。

### 我可以用 IP 白名单代替密码登录吗？

可以。所有套餐均支持用户名和密码，或 IP 白名单（最多 10 个 IP）。拥有独立凭据和流量上限的子用户。可随时撤销的 API 密钥。[文档](https://eurocityproxies.com/zh/docs/) 说明了从白名单 IP 连接时如何设置国家和城市。本页示例使用用户名和密码，因为它们在任意机器上都能用。

### 第一个 GB 怎么付款？

选择套餐，然后用 BTC, USDT, USDC, ETH, SOL, LTC 按其价格充值（最低 US$25）。发送准确金额并点击“我已发送付款”；充值会按准确金额匹配，确认后即入账。无需 KYC：注册、充值或购买均无需身份证、自拍或文件。

## 来源

1. [curl 手册页：--proxy、socks5h:// 和 --socks5-hostname](https://curl.se/docs/manpage.html) — curl project (checked 2026-10-18)
2. [Requests：高级用法、代理和 SOCKS](https://requests.readthedocs.io/en/latest/user/advanced/) — Python Software Foundation / Requests (checked 2026-10-18)
3. [HTTPX：代理](https://www.python-httpx.org/advanced/proxies/) — Encode (checked 2026-10-18)
4. [undici ProxyAgent 文档](https://github.com/nodejs/undici/blob/main/docs/docs/api/ProxyAgent.md) — Node.js project (checked 2026-10-18)
5. [Node.js 版本（受支持的发布线）](https://nodejs.org/en/about/previous-releases) — OpenJS Foundation (checked 2026-10-18)
6. [Chrome 中的代理支持（SOCKSv5 认证）](https://chromium.googlesource.com/chromium/src/+/HEAD/net/docs/proxy.md) — The Chromium Projects (checked 2026-10-18)
7. [为 Android 模拟器设置代理](https://developer.android.com/studio/run/emulator-networking-proxy) — Google / Android Developers (last updated 2026-03-12, checked 2026-10-18)
8. [全局 HTTP 代理设备管理载荷设置（iOS、iPadOS：使用用户名和密码的手动代理）](https://support.apple.com/guide/deployment/global-http-proxy-payload-settings-dep7ba46fcd/web) — Apple Platform Deployment (checked 2026-10-18)
9. [RFC 9110 HTTP 语义，第 9.3.6 节 CONNECT 和状态 407](https://www.rfc-editor.org/rfc/rfc9110.html) — IETF (June 2022, checked 2026-10-18)
10. [IPinfo JSON 端点](https://ipinfo.io/json) — IPinfo (checked 2026-10-18)

---

EuroCity Proxies: EuroCity Proxies 是一家住宅代理服务商，提供覆盖欧洲的城市级定位，支持加密货币支付、无需上传身份证件：家庭宽带 IP 按 GB 计费，并为 35 个国家/地区的 103 个城市各提供一页本地数据。
