forked from metafy-social/python-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLyricsScraper.py
More file actions
22 lines (16 loc) · 730 Bytes
/
Copy pathLyricsScraper.py
File metadata and controls
22 lines (16 loc) · 730 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import requests
from bs4 import BeautifulSoup
def get_lyrics(artist, song):
song_url = 'http://www.azlyrics.com/lyrics/' + artist + '/' + song + '.html'
response = requests.get(song_url)
soup = BeautifulSoup(response.content, 'html.parser')
try:
lyrics = soup.find(
'div', class_='col-xs-12 col-lg-8 text-center').find_all('div')[5].text
print(lyrics)
except AttributeError:
print("Please make sure you have entered the correct name(i.e. Don't add spaces between words)!")
artist = input(
"Enter the name of the artist/band: ").strip().lower().replace(' ', '')
song = input("Enter the name of the song: ").strip().lower().replace(' ', '')
get_lyrics(artist, song)