简体   繁体   English

Python:请求代理不起作用

[英]Python: Requests Proxies not working

I am trying to access a proxy, that I have ping multiple times and is online, to do a search. 我试图访问一个代理,该代理多次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

This is my code. 这是我的代码。 I use regular expressions to search the html code for mentions of the IP and it always only returns my current IP. 我使用正则表达式在html代码中搜索提及IP的内容,并且它始终仅返回我当前的IP。 I tried different websites that tell me my IP and everyone of them returns my current IP and not my proxy. 我尝试了不同的网站来告诉我我的IP,每个人都返回我当前的IP,而不是我的代理。 Any suggestion on what I am doing wrong. 关于我在做什么错的任何建议。

Your proxy is http while your request address is a https. 您的代理服务器为http,而您的请求地址为https。 You need to have another proxy for https requests. 您需要为https请求设置另一个代理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM