Python:请求代理不起作用

Dav*_*ico 5 python proxy

我正在尝试访问一个代理,我多次 ping 并且在线,以进行搜索。

import requests
import re

s = requests.Session() 
s.proxies = {'http': 'http://11.22.33.4455'}

r = s.get('https://www.iplocation.net/find-ip-address')

data = r.text

regex = r"1.2.3.45"  # Proxy IP
regex2 = r"6.7.8.99"  # My IP

matches = re.findall(regex, data)
matches2 = re.findall(regex2, data)

print(matches)
print(matches2)  # Always prints out my current IP and not my proxy
Run Code Online (Sandbox Code Playgroud)

这是我的代码。我使用正则表达式在 html 代码中搜索 IP 的提及,它总是只返回我当前的 IP。我尝试了不同的网站,这些网站告诉我我的 IP,他们每个人都返回我当前的 IP,而不是我的代理。关于我做错了什么的任何建议。

小智 7

您的代理是 http 而您的请求地址是 https。您需要为 https 请求设置另一个代理。