Python download mp3 from url

I'm trying to learn Python and I tried to write a code to download all the bible mp3 files from my church website where there's a list of mp3 hyperlinks such as:

Chapter 1, Chapter 2,3,4,5 and so on... Reference link

I managed to get all the mp3 URL links to show on the shell after running my code but I can't seem to be able to download them at all.

Here's my code

import requests
import urllib.request
import re
from bs4 import BeautifulSoup

r = requests.get('https://ghalliance.org/resource/bible-reading')
soup = BeautifulSoup(r.content, 'html.parser')

for a in soup.find_all('a', href=re.compile('http.*\.mp3')):
    print(a['href'])

I did try using wget but I can't seem to get wget to work on my machine running VSCode Python 3.8.1 64-bit or conda 3.7.4... I've checked both conda cmd and cmd and it showed that I had wget in my system, I even manually download the wget.exe to my system32 directory but whenever I tried to run the

wget.download(url)

I always get an error message or something like wget has no attribute 'download' or whatnot.

I read a few beginner tutorials on using selenium, wget, beautifulsoup to download simple pictures, etc but I can't seem to incorporate their method to work on this specific problem of mine...cuz I'm still too new to programming in general, so I apologize for asking stupid dumb questions like these.

But now that I had all my MP3 URL links, so my question is: how do I go about downloading them using Python?

A simple python program to download in a simple way a mp3 on mp3skull.com. Features : Search, result list, download

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 urllib2, urllib
number_of_result = 20
def get_page(query):
page_source = urllib2.urlopen("http://mp3skull.com/mp3/{}.html".format(query.replace(" ","_"))).read()
return page_source
def get_link(page_source, n):
# "n" is the position in the list in the results
result_start = '
'
pos1 = page_source.find(result_start.format(n)) #The position at which the source code starts for a specific n result
link_indicator = ', link_start)
link = page_source[link_start:link_end]
return link
def get_results(page_source):
n = 1
result = []
while n < number_of_result:
pos1 = page_source.find('
'.format(n))
if pos1 == -1:
break
title_start = page_source.find("", pos1)+3
title_end = page_source.find(", title_start)
title = page_source[title_start:title_end]
result.append(title)
n += 1
return result
def get_size(link):
try:
return int(urllib.urlopen(link).headers.get("Content-Length"))
except:
return 0
def download(link, filename = ""):
if filename == "":
filename = link.split("/")[-1]
print "File size: {} MB (0 means unknown)".format(str(get_size(link)/10.0**6)[:5])
print "Downloading..."
try:
urllib.urlretrieve(link, filename)
except:
print "404: Couldn't download file"
print "Done!"
def download_using_wget(link): # Use instead if you have wget
from os import system
system('wget -c "{}"'.format(link))
def main():
print "MP3skull downloader\nMade by RK11\n"
query = raw_input("Query: ")
page = get_page(query)
n = 1
results = get_results(page)
for title in results:
print "{}.{}".format(n, title)
n += 1
n = input("Which track do you want to download ? ")
download(get_link(page, n)) # You can replace by download_with_wget()
print "\nThank you for using this program !\n"
main()

How do I download an audio file from a URL in Python?

How to Download a File Using urllib Module in Python.
Import the urllib module into your project..
Use urllib's request. urlretrieve() method to download a file from a specific URL and save it on your machine..

How do you download data from a URL in Python?

Import module. import requests..
Get the link or url. url = 'https://www.facebook.com/favicon.ico' r = requests.get(url, allow_redirects=True).
Save the content with name. open('facebook.ico', 'wb').write(r.content) save the file as facebook. ico..

How do I download music with Python?

Looking to build projects on Python?: Download and install python latest version. Install spot-dl packages with the help of pip. Copy-paste the song or playlist link to download.

How do I automatically download a file from a website using Python?

“how to automate downloading a file from a website using python” Code Answer's.
import urllib. request..
pdf_path = "".
def download_file(download_url, filename):.
response = urllib. request. urlopen(download_url).
file = open(filename + ".pdf", 'wb').
file. write(response. read()).
file. close().