Upload files to ''

This commit is contained in:
siengrain 2021-12-20 23:01:00 +00:00
parent aa0f8f3c15
commit 36a2a8e15b
1 changed files with 34 additions and 0 deletions

34
letras.py Normal file
View File

@ -0,0 +1,34 @@
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('</p>,', '\n')
lyrics = lyrics.replace('<br/>,', '\n')
lyrics = lyrics.replace('<br/>', '\n')
lyrics = lyrics.replace('<p>', '')
lyrics = lyrics.replace('<br>', '\n')
lyrics = lyrics.replace('</br>', '\n')
lyrics = lyrics.replace('<p style="display: none;">Quiero recibir notificaciones de artistas destacados y noticias.<span class="bt-toggle" id="js-toggle-push"></span></p>', '')
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 <b>amor</b> en Belo Horizonte - Brasil', '')
return('\n'+lyrics[1:-1])