def _scrape_song_lyrics_from_url(self, url):
        """ Use BeautifulSoup to scrape song info off of a Genius song URL
        :param url: URL for the web page to scrape lyrics from
        """
        page = requests.get(url)
        if page.status_code == 404:
            return None

        # Scrape the song lyrics from the HTML
        html = BeautifulSoup(page.text, "html.parser")
        div = html.find("div", class_="lyrics")
        if not div:
            return None # Sometimes the lyrics section isn't found

        # Scrape lyrics if proper section was found on page
        lyrics = div.get_text()
        if self.remove_section_headers:  # Remove [Verse], [Bridge], etc.
            lyrics = re.sub('(\[.*?\])*', '', lyrics)
            lyrics = re.sub('\n{2}', '\n', lyrics)  # Gaps between verses
        return lyrics.strip("\n")
def _scrape_song_lyrics_from_url ( self , url ) : page = requests . get ( url ) if page . status_code == 404 : return None html = BeautifulSoup ( page . text , "html.parser" ) div = html . find ( "div" , class_ = "lyrics" ) if not div : return None lyrics = div . get_text ( ) if self . remove_section_headers : lyrics = re . sub ( '(\[.*?\])*' , '' , lyrics ) lyrics = re . sub ( '\n{2}' , '\n' , lyrics ) return lyrics . strip ( "\n" )
Use BeautifulSoup to scrape song info off of a Genius song URL
        :param url: URL for the web page to scrape lyrics from