class BindableHTTPHandler(urllib.request.HTTPHandler):

    def http_open(self, req):
        return self.do_open(BindableHTTPConnectionFactory('127.0.0.1'), req)
opener = urllib.request.build_opener(BindableHTTPHandler)
opener.open('http://google.com/').read()
Source interface with Python and urllib2