File tree Expand file tree Collapse file tree 3 files changed +32
-0
lines changed Expand file tree Collapse file tree 3 files changed +32
-0
lines changed 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
+ song_url = 'http://www.azlyrics.com/lyrics/' + artist + '/' + song + '.html'
7
+
8
+ response = requests .get (song_url )
9
+
10
+ soup = BeautifulSoup (response .content , 'html.parser' )
11
+ try :
12
+ lyrics = soup .find (
13
+ 'div' , class_ = 'col-xs-12 col-lg-8 text-center' ).find_all ('div' )[5 ].text
14
+ print (lyrics )
15
+ except AttributeError :
16
+ print ("Please make sure you have entered the correct name!" )
17
+
18
+
19
+ artist = input ("Enter the name of the artist/band: " ).strip ().lower ()
20
+ song = input ("Enter the name of the song: " ).strip ().lower ()
21
+ get_lyrics (artist , song )
Original file line number Diff line number Diff line change
1
+ # Lyrics scraper
2
+
3
+ This simple script scrapes [ Azlyrics] ( http://www.azlyrics.com ) given the artist and the song name.
4
+
5
+ ## Usage
6
+
7
+ It&apos ; s pretty straight-forward, just install the requiremnts and run it.
8
+
9
+ ` pip install -r requirements.txt `
Original file line number Diff line number Diff line change
1
+ bs4
2
+ requests
You can’t perform that action at this time.
0 commit comments