From be1a2446daedd2610a18447ffcaeaf7f9e10e938 Mon Sep 17 00:00:00 2001 From: Martin Wagner Date: Wed, 23 Sep 2020 21:36:38 +0200 Subject: [PATCH] now using built-in html.parser --- mpdevil/lyrics.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mpdevil/lyrics.py b/mpdevil/lyrics.py index 3d0aed8..36949c4 100644 --- a/mpdevil/lyrics.py +++ b/mpdevil/lyrics.py @@ -19,7 +19,7 @@ # USA import requests -from bs4 import BeautifulSoup, Comment +from bs4 import BeautifulSoup class LyricsHelper(object): def __init__(self, debug=False): @@ -37,7 +37,7 @@ class LyricsHelper(object): song=song.replace(char1, char2) self._debug_print('http://www.lyriki.com/{0}:{1}'.format(singer,song)) r=requests.get('http://www.lyriki.com/{0}:{1}'.format(singer,song)) - s=BeautifulSoup(r.text) + s=BeautifulSoup(r.text, 'html.parser') lyrics=s.p if lyrics is None: raise ValueError("Not found") @@ -58,7 +58,7 @@ class LyricsHelper(object): song=song.replace(char1, char2) self._debug_print('https://www.songlyrics.com/{0}/{1}-lyrics/'.format(singer,song)) r=requests.get('https://www.songlyrics.com/{0}/{1}-lyrics/'.format(singer,song)) - s=BeautifulSoup(r.text) + s=BeautifulSoup(r.text, 'html.parser') lyrics=s.find(id="songLyricsDiv") if lyrics is None: raise ValueError("Not found") @@ -79,13 +79,13 @@ class LyricsHelper(object): song=song.replace(char1, char2) self._debug_print('https://www.letras.mus.br/winamp.php?musica={1}&artista={0}'.format(singer,song)) r=requests.get('https://www.letras.mus.br/winamp.php?musica={1}&artista={0}'.format(singer,song)) - s=BeautifulSoup(r.text) + s=BeautifulSoup(r.text, 'html.parser') s=s.find(id="letra-cnt") if s is None: raise ValueError("Not found") - pragraphs=[i for i in s.children][2:-1] # remove unneded pragraphs + paragraphs=[i for i in s.children][1] # remove unneded paragraphs (NavigableString) lyrics="" - for p in pragraphs: + for p in paragraphs: for line in p.stripped_strings: lyrics+=line+'\n' lyrics+='\n'