pycurl cookies

Reply

Join Date: Jun 2008
Posts: 26
Reputation: krammer is an unknown quantity at this point 
Solved Threads: 0
krammer krammer is offline Offline
Light Poster

pycurl cookies

 
0
  #1
Jan 4th, 2009
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.

  1. def main():
  2.  
  3. # Request post page
  4. dev_null = StringIO.StringIO()
  5. pycurlConnect = pycurl.Curl()
  6. pycurlConnect.setopt(pycurl.USERAGENT, USER_AGENT)
  7. pycurlConnect.setopt(pycurl.URL, LOGIN_URL)
  8. pycurlConnect.setopt(pycurl.REFERER, REFERER)
  9. pycurlConnect.setopt(pycurl.POSTFIELDS, POST_DATA)
  10. pycurlConnect.setopt(pycurl.HTTPHEADER, HEADERS)
  11. pycurlConnect.setopt(pycurl.WRITEFUNCTION, dev_null.write)
  12. pycurlConnect.setopt(pycurl.COOKIEFILE, 'cookies.txt')
  13. pycurlConnect.setopt(pycurl.COOKIEJAR, 'cookies.txt')
  14. pycurlConnect.setopt(pycurl.POST, 1)
  15. pycurlConnect.setopt(pycurl.VERBOSE, 1)
  16. pycurlConnect.setopt(pycurl.FOLLOWLOCATION, 1)
  17. pycurlConnect.perform()
  18.  
  19. print pycurlConnect.getinfo(pycurl.HTTP_CODE), pycurlConnect.getinfo(pycurl.EFFECTIVE_URL)
  20. print pycurlConnect.getinfo(pycurl.INFO_COOKIELIST)
  21.  
  22. # Close connections
  23. dev_null.close()
  24. pycurlConnect.close()
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 26
Reputation: krammer is an unknown quantity at this point 
Solved Threads: 0
krammer krammer is offline Offline
Light Poster

Re: pycurl cookies

 
0
  #2
Jan 4th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 2,273
Reputation: sneekula has a spectacular aura about sneekula has a spectacular aura about 
Solved Threads: 175
sneekula's Avatar
sneekula sneekula is offline Offline
Nearly a Posting Maven

Re: pycurl cookies

 
0
  #3
Jan 6th, 2009
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?
Last edited by sneekula; Jan 6th, 2009 at 11:24 am.
No one died when Clinton lied.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 26
Reputation: krammer is an unknown quantity at this point 
Solved Threads: 0
krammer krammer is offline Offline
Light Poster

Re: pycurl cookies

 
0
  #4
Jan 6th, 2009
I've read pycurl is faster...it 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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 26
Reputation: krammer is an unknown quantity at this point 
Solved Threads: 0
krammer krammer is offline Offline
Light Poster

Re: pycurl cookies

 
0
  #5
Jan 7th, 2009
Do you know how to capture the cookies with cookielib and urllib2?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Python Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC