File tree 1 file changed +34
-0
lines changed
Automation/src/lyrics_fetcher
1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ #Displays Lyrics of song directly in terminal
2
+ #usage: python lyricsFetch.py [Artist_name] [song_name]
3
+ from bs4 import BeautifulSoup
4
+ import os
5
+ import sys
6
+ import requests
7
+ import webbrowser
8
+ import urllib2
9
+
10
+ if len (sys .argv )> 1 :
11
+ detail = '/' .join (sys .argv [1 :])
12
+ else :
13
+ print ('Please try again' )
14
+ sys .exit (1 )
15
+
16
+
17
+ songurl = 'http://www.azlyrics.com/lyrics/' + detail + '.html'
18
+ page = urllib2 .urlopen (songurl )
19
+
20
+ soup = BeautifulSoup (page ,'lxml' )
21
+
22
+ name_box = soup .find ('div' ,attrs = {'class' :'lyricsh' })
23
+ name = name_box .text .strip ()
24
+
25
+ print '\n '
26
+ print name
27
+ print '\n '
28
+
29
+ for foo in soup .find_all ('div' ,attrs = {'class' :'col-xs-12 col-lg-8 text-center' }):
30
+ lyric_box = foo .find ('div' ,attrs = {'class' :None })
31
+ lyric = lyric_box .text .strip ()
32
+ print lyric
33
+
34
+
You can’t perform that action at this time.
0 commit comments