Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #13103 > unrolled thread

Re: download pages using a cookies.txt file

Started byJabba Laci <jabba.laci@gmail.com>
First post2011-09-10 23:20 -0400
Last post2011-09-10 23:20 -0400
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: download pages using a cookies.txt file Jabba Laci <jabba.laci@gmail.com> - 2011-09-10 23:20 -0400

#13103 — Re: download pages using a cookies.txt file

FromJabba Laci <jabba.laci@gmail.com>
Date2011-09-10 23:20 -0400
SubjectRe: download pages using a cookies.txt file
Message-ID<mailman.965.1315711251.27778.python-list@python.org>
Hi,

Thanks, I could put together the pieces and here is my solution:

(1) get_cookies_in_cookiejar function to extract cookies and put them
in a cookiejar:
https://github.com/jabbalaci/jabbapylib/blob/master/jabbapylib/web/export_firefox_cookies.py

(2) download page using urllib2 and passing the cookiejar:
https://github.com/jabbalaci/jabbapylib/blob/master/jabbapylib/web/web.py
See the bottom with get_page_with_cookies_using_cookiejar(url).

Laszlo


On Mon, Sep 5, 2011 at 22:19, Chris Rebert <clp2@rebertia.com> wrote:
> On Mon, Sep 5, 2011 at 6:36 PM, Jabba Laci <jabba.laci@gmail.com> wrote:
>> Hi,
>>
>> I would like to download a page that requires authentication with
>> cookies. I've already figured out how to do it with wget (blog post
>> here: http://bit.ly/pp25LP). In short:
>> (1) extract cookies from Firefox's cookies.sqlite and store them in a text file
>> (2) wget --cookies=on --load-cookies=cookies.txt
>> --keep-session-cookies "http://..."
>>
>> My question is: how to do it from Python?
>
> http://docs.python.org/library/cookielib.html#cookielib.MozillaCookieJar
>
> Cheers,
> Chris
>

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web