1

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.

asked Feb 9, 2017 at 13:28

1 Answer 1

2

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.

answered Feb 10, 2017 at 9:08
Sign up to request clarification or add additional context in comments.

1 Comment

Ya that's what I also figured out after testing yesterday. Thanks for help @Rytis

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.