简体   繁体   中英

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.

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. I tried different websites that tell me my IP and everyone of them returns my current IP and not my proxy. Any suggestion on what I am doing wrong.

Your proxy is http while your request address is a https. You need to have another proxy for https requests.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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