This repository was archived by the owner on Nov 30, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +37
-0
lines changed
Web-Scraping/Songs_Lyrics Expand file tree Collapse file tree 3 files changed +37
-0
lines changed Original file line number Diff line number Diff line change 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+
Original file line number Diff line number Diff line change 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 )
You can’t perform that action at this time.
0 commit comments