I am using python requests to load a page using https proxy but its not working. The same code is working with http proxy.
The following is my code:
With https proxy
import requests
proxyDict = {'https': 'https://xxx.xxx.xxx.xxx:xx'}
r = requests.get('http://icanhazip.com', proxies=proxyDict)
print(r)
print(r.content)
Output:
Response [200]
xxx.xxx.xxx.xxx - the ip is for my server and not the proxy server
With http proxy
import requests
proxyDict = {'http': 'http://xxx.xxx.xxx.xxx:xx'}
r = requests.get('http://icanhazip.com', proxies=proxyDict)
print(r)
print(r.content)
Output:
Response [200]
xxx.xxx.xxx.xxx - the ip is for proxy server
How to use https proxy server with python requests?
Is there any error in my code? Or how to fix this issue?
Please help me with this issue.
1 Answer 1
In your first code example, you are using HTTPS proxy but making a request to HTTP site. You should do r = requests.get('https://icanhazip.com', proxies=proxyDict) instead.
1 Comment
Explore related questions
See similar questions with these tags.