johnwmillr / LyricsGenius

Download song lyrics and metadata from Genius.com 🎶🎤
http://www.johnwmillr.com/scraping-genius-lyrics/
MIT License
899 stars 159 forks source link

Error in using api.search_artist #93

Closed Dawei-Ding closed 5 years ago

Dawei-Ding commented 5 years ago

Describe the bug Here is my sample code:

api = lyricsgenius.Genius("my_access_token") artist = api.search_artist('Taylor Swift', max_songs=8) print(artist.songs)

The error: artist = api.search_artist('Taylor Swift', max_songs=8)

File "/anaconda2/lib/python3.6/site-packages/lyricsgenius/api.py", line 381, in search_artist lyrics = self._scrape_song_lyrics_from_url(song_info['url'])

File "/anaconda2/lib/python3.6/site-packages/lyricsgenius/api.py", line 144, in _scrape_song_lyrics_fromurl lyrics = html.find("div", class="lyrics").get_text()

AttributeError: 'NoneType' object has no attribute 'get_text'

Version info

johnwmillr commented 5 years ago

Hi Dawei,

What version of the package are you using? I don't get the same error when I run your code with the latest version (1.4.0).

John

Dawei-Ding commented 5 years ago

Hi John,

The package version is 1.4.0 My python version is 3.6.6 and macOS 10.14.4

johnwmillr commented 5 years ago

Did you copy the error message exactly? I'm curious because the latest version of the code has a trailing underscore after class:

Your error:

lyrics = html.find("div", class="lyrics").get_text()

Latest code:

lyrics = html.find("div", class_="lyrics").get_text()

PR #95 should address this issue. Update to version 1.5.1 of the package, and let me know if that solves your problem.

Dawei-Ding commented 5 years ago

Hi John,

It works now after I upgraded to 1.5.1. Thank you.

johnwmillr commented 5 years ago

Great!