Hello, here is my current code:<br>
<br>
import urllib, urllib2, cookielib<br>
<br>
class wrapper:<br>
    def __init__(self):<br>
        self.setupCookies()<br>
        <br>
    def request(self, address, postData=None, headers={ }):<br>
        if not postData == None:<br>
            postData = urllib.urlencode(postData)<br>
        req = urllib2.Request(address, postData, headers)<br>
        return urllib2.urlopen(req).read()<br>
<br>
    def loadCookies(self, cookieFile):<br>
        self.cookieJar.load(cookieFile)<br>
<br>
    def saveCookies(self, cookieFile):<br>
        self.cookieJar.save(cookieFile)<br>
        <br>
    def useProxy(self, proxy):<br>
        proxymap = {'http': proxy}<br>
        self.cookieJar = cookielib.LWPCookieJar()<br>
<br>
        director = urllib2.OpenerDirector()<br>
        director.add_handler(urllib2.ProxyHandler(proxymap))<br>
        director.add_handler(urllib2.HTTPCookieProcessor(self.cookieJar))<br>
<br>
        urllib2.install_opener(director)<br>
        <br>
    def setupCookies(self):<br>
        self.cookieJar = cookielib.LWPCookieJar()<br>
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cookieJar))<br>
        urllib2.install_opener(opener)<br>
<br>
proxyhttp = wrapper()<br>
proxyhttp.useProxy(proxy)<br>
postData = {'username': username, 'password': password}<br>
content = proxyhttp.request('<a href="http://blah.com/login.php">http://blah.com/login.php</a>', postData)<br>
<br>
Now, basically what this should do is send a POST request to login.php
using the given proxy and then save the returned cookies using the
cookie handler. Either I'm doing something wrong or the proxy and
cookie handler don't place nicely together. Here is the resulting error:<br>
<br>
  File "C:\Python25\neolib\wrapper.py", line 11, in request<br>
    return urllib2.urlopen(req).read()<br>
  File "C:\Python25\lib\urllib2.py", line 121, in urlopen<br>
    return _opener.open(url, data)<br>
  File "C:\Python25\lib\urllib2.py", line 380, in open<br>
    response = meth(req, response)<br>
  File "C:\Python25\lib\urllib2.py", line 1124, in http_response<br>
    self.cookiejar.extract_cookies(response, request)<br>
  File "C:\Python25\lib\cookielib.py", line 1627, in extract_cookies<br>
    _debug("extract_cookies: %s", response.info())<br>
AttributeError: 'NoneType' object has no attribute 'info'<br>
<br>
I don't know much about these handlers to really understand what's
going wrong. I assume it has to be something with these two handlers
conflicting because I can't seem to find anything wrong with my code.
Is this a bug or am I doing something wrong? Help is much appreciated,
thanks.<br>
<br>
Cheers,<br>
Josh<br>