Created
March 2, 2020 02:08
-
-
Save tahnok/c0b07f8d212c2df36e259c979ea0cabe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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