[twill] Downloading a binary file

Jamal Mazrui Jamal.Mazrui at fcc.gov
Fri Sep 4 07:10:59 PDT 2009

Awesome, that worked -- thanks, Titus!  By the way, I have researched
similar libraries in Python, Ruby, AutoIt, JavaScript, and .NET, and
found nothing currently comparable to twill in terms of the combination
of power and friendliness.


-----Original Message-----
From: C. Titus Brown [mailto:ctb at msu.edu] 
Sent: Thursday, September 03, 2009 10:31 PM
To: Jamal Mazrui
Cc: twill at lists.idyll.org
Subject: Re: [twill] Downloading a binary file

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