MooreFRCollections / ideas /get_audio_mp3_link.py
sawadogosalif's picture
Update ideas/get_audio_mp3_link.py
41c4354 verified
raw
history blame contribute delete
596 Bytes
import requests
from bs4 import BeautifulSoup
def extract_mp3_link(page_url):
try:
response = requests.get(page_url)
response.raise_for_status()
soup = BeautifulSoup(response.text, "html.parser")
audio_div = soup.find("div", class_="jsAudioPlayer")
mp3_link = audio_div.find("a", class_="streaming")["href"]
return mp3_link
except Exception as e:
print(f"Erreur lors de l'extraction du lien MP3 : {e}")
return None
url = "https://www.jw.org/mos/d-s%E1%BA%BDn-yiisi/biible/nwt/books/S%C9%A9ngre/50/"
extract_mp3_link(url)