from bs4 import BeautifulSoup import requests from requests import get def getLink(artist, title): base_start = 'https://www.letras.com/' artist = artist.lower() artist = artist.replace(' ', '-') title = title.lower() title = title.replace(' ', '-') link = base_start + artist + '/' + title return(link) def getLyrics(link): w = requests.get(link) soup = BeautifulSoup(w.text, 'html.parser') lyr = soup.find_all('p', class_=False) let = str(lyr) return(let) def parsero(lyrics): lyrics = lyrics.replace('

,', '\n') lyrics = lyrics.replace('
,', '\n') lyrics = lyrics.replace('
', '\n') lyrics = lyrics.replace('

', '') lyrics = lyrics.replace('
', '\n') lyrics = lyrics.replace('
', '\n') lyrics = lyrics.replace('

Quiero recibir notificaciones de artistas destacados y noticias.

', '') lyrics = lyrics.replace('Música comienza con letras', '') lyrics = lyrics.replace('Asociados:', '') lyrics = lyrics.replace(' © 2003 - 2021, 3.1 millones de canciones', '') lyrics = lyrics.replace(' Hecho con amor en Belo Horizonte - Brasil', '') return('\n'+lyrics[1:-1])