[twill] Downloading a binary file

C. Titus Brown ctb at msu.edu
Thu Sep 3 19:30:59 PDT 2009

On Thu, Sep 03, 2009 at 06:04:22PM -0400, Jamal Mazrui wrote:
-> I want to develop a web crawler with twill.  What might be the best way
-> to download non-HTML files while retaining state?  For example, a script
-> might log into a site and then search for particular .mp3 files there.
-> I want cookies and the Referer header to be handled correctly when
-> making a download request.  I have found twill examples that save
-> text/HTML but not binary files.

Hi Jamal,

try this:

import twill
b = twill.get_browser()
b.go('http://some/url/')  # <-- REPLACE WITH ACTUAL URL

data = b.result.get_page()

C. Titus Brown, ctb at msu.edu

More information about the twill mailing list