知识库 / 使用与配置

在代码中使用

curl、Python、Node.js 示例。

把下面示例里的地址、端口、账号、密码换成你自己的。

curl

bash
curl -x http://user:pass@1.2.3.4:8000 https://api.ipify.org
# SOCKS5
curl -x socks5h://user:pass@1.2.3.4:8000 https://api.ipify.org

Python (requests)

python
import requests
proxy = "http://user:pass@1.2.3.4:8000"
r = requests.get("https://api.ipify.org", proxies={"http": proxy, "https": proxy}, timeout=15)
print(r.text)

SOCKS5 需要先 pip install requests[socks],把 http:// 换成 socks5h://。

Node.js

js
import { ProxyAgent, fetch } from "undici";
const agent = new ProxyAgent("http://user:pass@1.2.3.4:8000");
const res = await fetch("https://api.ipify.org", { dispatcher: agent });
console.log(await res.text());
还有问题?提交工单,客服会尽快回复。联系客服 →