Skip to content
This repository was archived by the owner on Nov 30, 2022. It is now read-only.

Commit 7089957

Browse files
authored
Merge pull request #260 from rutujadhanawade/song_lyrics
song lyrics scraper
2 parents 5e512fb + 9b23056 commit 7089957

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

Web-Scraping/Songs_Lyrics/README.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Songs lyrics scrapper
2+
3+
### This script takes input artist name and song name and gives the lyrics of the song by scrping from 'http://www.azlyrics.com/'.
4+
5+
##### Technolgies:
6+
7+
- BeautifulSoup
8+
- requests
9+
10+
##### output:
11+
12+
![output](lyrics_op.png)
13+
14+
94.1 KB
Loading
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import requests
2+
from bs4 import BeautifulSoup
3+
4+
5+
def get_lyrics(artist, song):
6+
base_url = 'http://www.azlyrics.com/'
7+
song_url = 'http://www.azlyrics.com/lyrics/' + artist + '/' + song + '.html'
8+
9+
# Use requests library to get html from artist's page
10+
response = requests.get(song_url)
11+
12+
# Make the html soup object
13+
soup = BeautifulSoup(response.content, 'html.parser')
14+
try:
15+
lyrics = soup.find('div' , class_ = 'col-xs-12 col-lg-8 text-center').find_all('div')[5].text
16+
print(lyrics)
17+
except AttributeError:
18+
print("Either this song doesnt exist or make sure you have entered the correct spelling!!")
19+
20+
21+
artist = input("Enter the name of the artist/band ")
22+
song = input("Enter the name of the song ")
23+
get_lyrics(artist, song)

0 commit comments

Comments
 (0)