[twill] set cookie during script
norman at khine.net
Wed May 13 13:07:21 PDT 2009
Thanks for your reply. This is what I ended up doing in the end.
cookie = open("cookies.txt", "a+")
domain="localhost"; path_spec; discard; version=0""")
It seems a bit long, perhaps there should be a set_cookie() method
On Wed, May 13, 2009 at 6:03 PM, Jesse London <jesselondon at gmail.com> wrote:
> Hi Norman,
> I'm not sure if you're using the Twill commands module, the Browser object,
> or twill-sh; but it looks like regardless there're both the methods
> "save_cookies" and "load_cookies" -- the former saves the contents of your
> cookie jar to a file, and the latter replaces your cookie jar's contents
> with those of a file.
> Unfortunately, that means you can't just "insert" a cookie, as far as I can
> tell. But, to get the functionality you want, I believe you can:
> 1) use "save_cookies /some/path" to save your already-loaded cookies to an
> existing (empty) file
> 2) append the new cookie to that file
> 3) use "load_cookies /some/path" to load all the cookies back into your jar
> Of course, especially if the cookie you want to insert is static, you could
> set up your file with it initially, and see if Twill is nice enough to not
> overwrite it with save_cookies.
> If you are doing this entirely in twill-sh, though, you're operating outside
> of what I'm really familiar with, and there might be some parts you'll have
> to do in Python (with the "run" command -- e.g. step 2).
> Good luck,
> On Tue, May 12, 2009 at 6:06 PM, Norman Khine <norman at khine.net> wrote:
>> I have the latest twill setup and all works well, but have a question
>> concerning cookies.
>> On a page, I would like to insert a specific cookie, and at the same
>> time keep the cookies that are already loaded. Is there a way to do
>> For example, the cookie I want to set is:
>> Set-Cookie3: tmain_referrer="http://localhost/index.php" path="/";
>> domain="localhost"; path_spec; discard; version=0
>> twill mailing list
>> twill at lists.idyll.org
More information about the twill