Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

How to get a complete cookies

python cookie

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1 Onodera

Onodera

    CC Newcomer

  • Member
  • PipPip
  • 13 posts

Posted 15 December 2014 - 08:14 PM

Hi

 

I have a script which connects and to get the cookies but he(it) is not complete all work juste the cookies is not complete

import pycurl
import urllib
import StringIO

def test(debug_type, debug_msg):
    if len(debug_msg) < 300:
        print "debug(%d): %s" % (debug_type, debug_msg.strip())    

pf = {'username' : 'user', 'password' : 'pw' }
fields = urllib.urlencode(pf)
pageContents = StringIO.StringIO()

p = pycurl.Curl()
p.setopt(pycurl.FOLLOWLOCATION, 1)
p.setopt(pycurl.COOKIEFILE, './cookies.txt')
p.setopt(pycurl.COOKIEJAR, './cookies.txt')
p.setopt(pycurl.POST, 1)
p.setopt(pycurl.POSTFIELDS, fields)
p.setopt(pycurl.WRITEFUNCTION, pageContents.write)
p.setopt(pycurl.VERBOSE, True)
p.setopt(pycurl.DEBUGFUNCTION, test)
p.setopt(pycurl.URL, 'http://animedigitalnetwork.fr/index.php/connexion')
p.perform()

p.close() # This is mandatory.

pageContents.seek(0)

ty


Edited by Onodera, 15 December 2014 - 08:14 PM.


#2 BlackRabbit

BlackRabbit

    CodeCall Legend

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3871 posts

Posted 17 December 2014 - 07:05 PM

You should try with cookielib or cookiejar.



#3 Onodera

Onodera

    CC Newcomer

  • Member
  • PipPip
  • 13 posts

Posted 17 December 2014 - 07:22 PM

Would it be possible to get an example? I'm better at understanding if i can see it.



#4 BlackRabbit

BlackRabbit

    CodeCall Legend

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3871 posts

Posted 17 December 2014 - 07:49 PM

Here is a cookielib example .