2

I am new to networking and proxy. For a project I need to give a proxy connection.

I already have a connection and I want change the connection behavior of the process to connect through that proxy. I would also like it to use a new IP in the event that it detects that it has been throttled.

The new connection process that I want is: connect from our server -> proxy -> required site if we are throttled: establish new connection through proxy (need to confirm new IP is being allocated by the proxy).

peterh
  • 4,953
  • 13
  • 30
  • 44

1 Answers1

2

Try this piece of code

proxy = urllib2.ProxyHandler({'http': '127.0.0.1:8080'})
opener = urllib2.build_opener(proxy)
urllib2.install_opener(opener)
urllib2.urlopen('http://www.google.com')
Maxiko
  • 474
  • 2
  • 8
  • Although the code is appreciated, it should always have an accompanying explanation. This doesn't have to be long but it is expected. – peterh Jun 17 '15 at 12:07