Re: How to keep cookies when making http requests (Python 2.7)

2013-08-30 Thread Luca Cerone
Thanks Dieter, > With respect to cookie handling, you do everything right. > > > > There may be other problems with the (wider) process. > > Analysing the responses of your requests (reading the status codes, > > the response headers and the response bodies) may provide hints > > towards th

Re: How to keep cookies when making http requests (Python 2.7)

2013-08-27 Thread dieter
Luca Cerone writes: > ... > Ok so after reading the documentation for urllib2 and cookielib I came up > with the following code: > > #START > from urllib2 import urlopen , Request > from cookielib import CookieJar > import re > regex = re.compile(r'\{(.*)\}') > > base_url = "http://quiz.gambitre

Re: How to keep cookies when making http requests (Python 2.7)

2013-08-27 Thread Luca Cerone
> > > Let me make an additional remark however: you should > > not expect to get complete details in a list like this - but only > > hints towards a solution for your problem (i.e. > > there remains some work for you). > > Thus, I expect you to read the "cookielib/cookiejar" documentation > > (pa

Re: How to keep cookies when making http requests (Python 2.7)

2013-08-27 Thread Luca Cerone
Dear all, first of all thanks for the help. As for your remark, you are right, and I usually tend to post questions in a way that is detached from the particular problem I have to solve. In this case since I only have a limited knowledge of the cookies mechanism (in general, not only in Python),

Re: How to keep cookies when making http requests (Python 2.7)

2013-08-21 Thread dieter
Luca Cerone writes: >... > Have you tried this code to check if this work? Not this code, but code like this (as I have written). > If it works as intended can you explain a bit better > what it does exactly? Fabio already did the explanation. Let me make an additional remark however: you sh

Re: How to keep cookies when making http requests (Python 2.7)

2013-08-21 Thread Fábio Santos
On 21 Aug 2013 09:22, "Luca Cerone" wrote: > > > > > I have used "cookielib" externally to "urllib2". It looks > > > > like this: > > > > from urllib2 import urlopen, Request > > > > from cookielib import CookieJar > > cookies = CookieJar() > > > > > > > > r = Request(...) > > > > cookies.add

Re: How to keep cookies when making http requests (Python 2.7)

2013-08-21 Thread Luca Cerone
> > I have used "cookielib" externally to "urllib2". It looks > > like this: > > from urllib2 import urlopen, Request > > from cookielib import CookieJar > cookies = CookieJar() > > > > r = Request(...) > > cookies.add_cookie_header(r) # set the cookies > > R = urlopen(r, ...) # make t

Re: How to keep cookies when making http requests (Python 2.7)

2013-08-20 Thread dieter
Luca Cerone writes: > ... Python has a module for cookie handling: "cookielib" ("cookiejar" in Python 3). "urllib2" has a standard way to integrate with this module. However, I do not know the details (check the documentation for the modules). I have used "cookielib" externally to "urllib2". It

How to keep cookies when making http requests (Python 2.7)

2013-08-20 Thread Luca Cerone
Hi everybody, I am trying to write a simple Python script to solve the "riddle" at: http://quiz.gambitresearch.com/ The quiz is quite easy to solve, one needs to evaluate the expression between the curly brackets (say that the expression has value ) and go to the web page: http://quiz.gambitrese