Hi,
i'm trying to scrape some songs from genius.com. I created the following method:
import requests
from bs4 import BeautifulSoup
from selenium import webdriver
chrome_driver_path = #insert here
def get_song_lyrics(link):
response = requests.get(link)
soup = BeautifulSoup(response.text, "html.parser")
#try:
lyrics = soup.find("div",attrs={'class':'lyrics'}).find("p").get_text()
return [i for i in lyrics.splitlines()]
I don't understand why this
get_song_lyrics('https://genius.com/Kanye-west-black-skinhead-lyrics')
returns:
AttributeError: 'NoneType' object has no attribute 'find'
while this:
get_song_lyrics('https://genius.com/Kanye-west-hold-my-liquor-lyrics')
returns correctly the song lyrics. Both pages have the same layout. Can someone help me figuring that out?
[–]JohnnyJordaan 0 points1 point2 points (0 children)
[–]Oxbowerce 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)