SOCKS5 代理支持更多协议,适合需要高兼容性的场景
| 对比项 | HTTP 代理 | SOCKS5 代理 |
|---|---|---|
| 支持协议 | HTTP/HTTPS | 任意 TCP/UDP |
| 匿名性 | 较低 | 较高 |
| 速度 | 较快 | 稍慢 |
| 兼容性 | 广泛支持 | 需要程序支持 |
安装依赖:
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 --socks5 ip:port --proxy-user username:password https://example.com
wget:
export all_proxy=socks5://username:password@ip:port
wget https://example.com