Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Download quran audio
import urllib.request
import os
from xml.dom.minidom import parse, parseString
def download(sura, ayas):
for aya in range(1, ayas+1):
fname = f'{sura:03}{aya:03}.mp3'
if not os.path.isfile(fname):
url = f'{sura:03}{aya:03}.mp3'
urllib.request.urlretrieve(url, fname)
if __name__=='__main__':
d = parse('quran-data.xml')
suras = d.getElementsByTagName('sura')
for s in suras:
sura = int(s.getAttribute('index'))
ayas = int(s.getAttribute('ayas'))
download(sura, ayas)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment