Answer the question
In order to leave comments, you need to log in
How to download mp3 using requests and python?
Hello! How can I download an mp3 file from this site https://r.megapesni.me/rap_2018/140731-miyagi-capt... using requests? Is it possible?
Answer the question
In order to leave comments, you need to log in
import requests
from bs4 import BeautifulSoup
host = 'https://megapesni.club'
link = 'https://megapesni.club/rap_2018/140731-miyagi-captain.html'
headers = {'user-agent':'Hottabxp - Cool Hacker!'}
response = requests.get(link, headers=headers)
soup = BeautifulSoup(response.text,'html.parser')
song_title = soup.find('h1',class_='music-title').text
url = soup.find('a',class_='song-author-btn song-author-btn--download').get('href')
response = requests.get(host+url,headers=headers)
with open(song_title+'.mp3','wb') as mp3:
mp3.write(response.content)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question