⚙️ 代理配置

SOCKS5 代理配置

SOCKS5 代理支持更多协议,适合需要高兼容性的场景

SOCKS5 vs HTTP 代理

对比项HTTP 代理SOCKS5 代理
支持协议HTTP/HTTPS任意 TCP/UDP
匿名性较低较高
速度较快稍慢
兼容性广泛支持需要程序支持
建议: 一般数据采集使用 HTTP 代理即可;需要更高匿名性或使用非 HTTP 协议时选择 SOCKS5。

Python 配置 SOCKS5

安装依赖:

pip install requests[socks]

使用示例:

import requests

proxies = {
    'http': 'socks5://username:password@ip:port',
    'https': 'socks5://username:password@ip:port'
}

response = requests.get('https://example.com', proxies=proxies)

命令行工具配置

curl:
curl --socks5 ip:port --proxy-user username:password https://example.com
wget:
export all_proxy=socks5://username:password@ip:port
wget https://example.com

本分类其他文章

HTTP/HTTPS 代理配置Chrome 浏览器代理配置移动端代理配置