Skip to content

Instantly share code, notes, and snippets.

@tahnok
Created March 2, 2020 02:08
Show Gist options
  • Save tahnok/c0b07f8d212c2df36e259c979ea0cabe to your computer and use it in GitHub Desktop.
Save tahnok/c0b07f8d212c2df36e259c979ea0cabe to your computer and use it in GitHub Desktop.
import xml.etree.ElementTree as ET
import requests
raw = requests.get("http://www.threesixtyrecords.net/podcasts/radiothreesixtyacc.xml").content
root = ET.fromstring(raw)
urls = [item.find('enclosure').get('url') for item in root[0].findall('item')]
for url in urls:
filename = url.split("/")[-1]
response = requests.get(url)
if response.status_code == requests.codes.ok:
with open(filename, 'wb') as fd:
for chunk in response.iter_content(chunk_size=129):
fd.write(chunk)
print(f"{filename} saved")
else:
print(f"{filename} failed to download {url}")
print("done")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment