My problem is that I do not see cookies being captured with this forum submission that I have setup. Does anyone know what I am doing wrong? Any help is appreciated, thanks.

def main():

   # Request post page
   dev_null = StringIO.StringIO()
   pycurlConnect = pycurl.Curl()
   pycurlConnect.setopt(pycurl.USERAGENT, USER_AGENT)
   pycurlConnect.setopt(pycurl.URL, LOGIN_URL)
   pycurlConnect.setopt(pycurl.REFERER, REFERER)
   pycurlConnect.setopt(pycurl.POSTFIELDS, POST_DATA)
   pycurlConnect.setopt(pycurl.HTTPHEADER, HEADERS)
   pycurlConnect.setopt(pycurl.WRITEFUNCTION, dev_null.write)
   pycurlConnect.setopt(pycurl.COOKIEFILE, 'cookies.txt')
   pycurlConnect.setopt(pycurl.COOKIEJAR, 'cookies.txt')
   pycurlConnect.setopt(pycurl.POST, 1)
   pycurlConnect.setopt(pycurl.VERBOSE, 1)
   pycurlConnect.setopt(pycurl.FOLLOWLOCATION, 1)

   print pycurlConnect.getinfo(pycurl.HTTP_CODE), pycurlConnect.getinfo(pycurl.EFFECTIVE_URL)
   print pycurlConnect.getinfo(pycurl.INFO_COOKIELIST)

   # Close connections

Actually I think my problem might be because of my print function, I forgot python 3.0 uses the parenthesis...although I still should have seen the cookies in the pcap file that I captured, so maybe the new print function is not my issue.

Also, Python30 should give you an error if you use the print statement instead of the print function.

Do you find pycurl easier to use than the usual cookielib and urllib2 modules that come with Python?

I've read pycurl is seems pretty easy to me...except for the cookie part. I'm pretty new to python so I've never used cookielib or urllib2, but i've looked at some examples and pycurl seems easier.

Do you know how to capture the cookies with cookielib and urllib2?

This article has been dead for over six months. Start a new discussion instead.