Working with Javascript loading needed cookies
#1
Photo 
Hi!

I am new to python and would need some help here.

I am currently writing a python video-add-on for a site with secure-login. I use cookielib to get the cookies of the response-header, but my problem is that some needed cookies come from javascript of the site.

How is it possilbe to get these cookies? I googled a little while and got results like "spynner", but i think it is a little bit too heavy for this application.

What lib is recommended in this case?


Thank you very, very much

vsvis
Reply
#2
Ok, this cookies are not necessary to stay logged in.

But although the cookie is saved correctly in the file it is not transfered to the site. Is there a way to see the sent header of the "opener.open(req)" ?

Code:
if os.path.exists(cookiepath):
                    print 'cookie exists'
                    cj = cookielib.LWPCookieJar()
                    cj.load(cookiepath)
                    req = urllib2.Request(url)
                    req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')  
                    opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
                    response = opener.open(req)
                    link=response.read()
                    response.close()
                    return link

Thank you!
Reply

Logout Mark Read Team Forum Stats Members Help
Working with Javascript loading needed cookies0