Created
March 17, 2016 02:35
-
-
Save ikouchiha47/13bde353a2d4a0d68dfe to your computer and use it in GitHub Desktop.
This file contains hidden or 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 requests | |
from bs4 import BeautifulSoup | |
url = 'http://webmusic.in/bengali_music.php?id=1066' | |
response = requests.get(url) | |
html = response.content | |
soup = BeautifulSoup(html, 'lxml') | |
songs = soup.find(id='lFs').find_all('a') | |
#song = soup.find(id='lFs').find('a') | |
def download_file(name): | |
url = 'http://34.webmusic.pw/34ej7/music/bengali/artist/m/manna_dey/best_of_manna_dey/%s_(webmusic.in).mp3' % name | |
r = requests.get(url, stream=True) | |
print 'Downloading ' + name + '.mp3 from ' + url | |
with open(name + '.mp3', 'wb') as f: | |
for chunk in r.iter_content(chunk_size=1024): | |
if chunk: | |
f.write(chunk) | |
return name | |
def download_songs(): | |
for row in songs: | |
t = "-".join(row.text.strip().split(' ')) | |
download_file(t) | |
download_songs() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment