Skip to content

Instantly share code, notes, and snippets.

@srounet
Created March 28, 2013 13:25
Show Gist options
  • Save srounet/5263101 to your computer and use it in GitHub Desktop.
Save srounet/5263101 to your computer and use it in GitHub Desktop.
Test Haproxy
#!/usr/bin/env python
import urllib2
import json
html = urllib2.urlopen('http://www.jsonip.com').read()
print "Normal ip: %s" % json.loads(html)['ip']
proxy_support = urllib2.ProxyHandler({"http":"http://127.0.0.1:8123"})
opener = urllib2.build_opener(proxy_support)
urllib2.install_opener(opener)
html = urllib2.urlopen("http://www.jsonip.com").read()
print "Proxy ip: %s" % json.loads(html)['ip']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment