
I just realised web proxy support would be much preferable to SOCKSv4 (long day, very tired)...so...to alter my question....does twisted have support for proxying connections through a web proxy? On Wed, Jul 23, 2008 at 3:46 PM, nnp <version5@gmail.com> wrote:
Hey,
I'm working on an app at the moment, part of which needs to grab a page from a website and parse the results. It will have to work in environments where connections have to be routed through a SOCKSv4 proxy but I can't find any way to specify a proxy using any of the Twisted classes. Is this possible? I assumed it was seeing as how it is a fairly common situation but the documentation/API haven't provided any useful information.
Cheers, nnp
Btw, my code currently looks like this :
from twisted.web.client import HTTPClientFactory from twisted.internet import ssl from twisted.internet import reactor from twisted.web import client
class BugGetter:
def __init__(self, url): ''' This class attempts to verify that a bug ID is a legitimate '''
self.url = url self.contextFactory = ssl.ClientContextFactory() self.scheme, self.host, self.port, path = client._parse(url)
def getPage(self, bugId): self.bugUrl = ''.join([self.url, bugId]) self.hcf = HTTPClientFactory(self.bugUrl) self.hcf.deferred.addCallback(self.parsePage) self.hcf.deferred.addErrback(self.errorCallback)
if scheme == 'https:': reactor.connectSSL(self.host, self.port, self.hcf, self.contextFactory) else: reactor.connectTCP(self.host, self.port, self.hcf)
reactor.run()
def parsePage(self): print self.hcf.status print self.hcf.message reactor.stop()
def errorCallback(self, failure): print failure.getErrorMessage() reactor.stop()
bz = Bugzilla('https://bugs.example.org/show_bug.cgi?id=') bz.getPage('9999')
-- http://www.smashthestack.org http://www.unprotectedhex.com
-- http://www.smashthestack.org http://www.unprotectedhex.com