4

How do I use Python to make an HTTP request through a proxy?

What do I need to do to the following code?

urllib.urlopen('http://www.google.com')

2 Answers 2

7

The urlopen function supports proxies. Try something like this:

urllib.urlopen(your_url, proxies = {"http" : "http://192.168.0.1:80"})
Sign up to request clarification or add additional context in comments.

2 Comments

Well, since those sites are not proxy servers you would require a very different solution. Technically a proxy server is a machine on your network that relays all internet traffic.
@AndrewHare A proxy server doesn't have to be on your local network at all. Can be on your local machine, local network, remote computer, wherever.
1

You could look at PycURL. I use cURL a lot in PHP and i love it. Though there is probably a neat way to do this currently in Python.

Comments

Your Answer

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.