I would like to download binary data (a .wav
file) from a website using python 3.
I was able to get the binary data as a string using requests.get
but when I tried to write it to a file, the data was changed and the saved file was not correct:
import requets
waveurl = 'http://www ..... /song.wav'
res = requests.get(waveurl)
with open("song.wav, "wb") as f:
f.write(bytes(res.text)
I also tried using struct.pack("B",each_byte)
but it didn't help.
How can I convert properly download and save binary data to a file without changing it?