<p>What's the best way of capturing an mp3 stream coming off of http and saving it to disk with python?</p>

<p>Thus far I've tried</p>

<pre><code>target = open(target_path, "w")
conn = urllib.urlopen(stream_url)
while True:
    target.write(conn.read(buf_size))
</code></pre>

<p>This gives me data but its garbled or wont play in mp3 players.</p>

If you're on Windows, you might accidentally be doing CRLF conversions, corrupting the binary data.  Try opening
```
target
```
in binary mode:
```
```
target = open(target_path, "wb")
```
```