Python requests.get不';我不在乎我的代理[http/https/sock4/sock5]

Python requests.get不';我不在乎我的代理[http/https/sock4/sock5],python,proxy,python-requests,Python,Proxy,Python Requests,我想测试列表中包含的代理的工作状态。 代理可以是HTTP/HTTPS或Socks4/socks5类型,其格式如下: 104.207.147.141:8080 103.216.51.210:8191 3.9.34.151:3128 191.232.214.74:8080 袜子4://138.59.143.37:57669 袜子4://185.169.181.24:4145 袜子4://45.115.112.214:40308 为了测试它们,我在站点上实现了一个请求,如果访问正确,该请求会将我的IP

我想测试列表中包含的代理的工作状态。 代理可以是HTTP/HTTPS或Socks4/socks5类型,其格式如下:

104.207.147.141:8080
103.216.51.210:8191
3.9.34.151:3128
191.232.214.74:8080
袜子4://138.59.143.37:57669
袜子4://185.169.181.24:4145
袜子4://45.115.112.214:40308

为了测试它们,我在站点上实现了一个请求,如果访问正确,该请求会将我的IP发回给我:

def tester(proxies, ip, ref_IPs):
  whitelist = []

  for proxy in range(0, len(proxies), 1):
    print(proxies[proxy])
    rep = requests.get("http://ifconfig.me/ip", {'http': proxies[proxy], 'https': proxies[proxy]}, timeout=1)
    if rep.text == ip:
        whitelist.append(ref_IPs[proxy])
    fileCreator(cleaner(whitelist, 1))
整个过程运行良好,但代理似乎对请求没有任何影响。因此,无论地址如何,代理都被视为功能性代理

191.232.214.74:8080->工作
袜子4://138.59.143.37:57669->工作
AAA.k4.yy.43:B345->工作


你能给我解释一下为什么吗?

请求。get拥有以下原型:

requests.get(url, params=None, **kwargs)
您需要的是kwargs中的参数“proxies”,因此您的请求必须如下所示:

rep = requests.get("http://ifconfig.me/ip", proxies={'http': proxies[proxy], 'https': proxies[proxy]}, timeout=1)