所以我用这个python包lyricsgenius
从网站上搜集歌词天才网使用网站的API。在这个脚本中,我希望它能搜集到300首德雷克的歌曲:
import lyricsgenius
genius = lyricsgenius.Genius(API_KEY)
artist = genius.search_artist("Drake", max_songs=300, sort="title")
但是,它在song 106处停止并显示错误消息:
Song 106: "Draft Day"
"Drake & DJ Semtex Interview" is not valid. Skipping.
Timeout raised and caught:
HTTPSConnectionPool(host='api.genius.com', port=443): Read timed out. (read timeout=5)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-2-575a1d98f954> in <module>
1 genius = lyricsgenius.Genius(API_KEY)
----> 2 artist = genius.search_artist("Drake", max_songs=300, sort="title")
~/anaconda3/lib/python3.7/site-packages/lyricsgenius/api.py in search_artist(self, artist_name, max_songs, sort, per_page, get_full_info, allow_name_change, artist_id)
329 else:
330 info = {'song': song_info}
--> 331 song = Song(info, lyrics)
332
333 # Attempt to add the Song to the Artist
~/anaconda3/lib/python3.7/site-packages/lyricsgenius/song.py in __init__(self, json_dict, lyrics)
24 save_lyrics: Save the song lyrics to a JSON or TXT file.
25 """
---> 26 self._body = json_dict['song'] if 'song' in json_dict else json_dict
27 self._body['lyrics'] = lyrics
28 self._url = self._body['url']
TypeError: argument of type 'NoneType' is not iterable
我如何设置,使它将停止刮时,它达到300首歌曲?你知道吗
意识到这是正在使用的
lyricsgenius
包中的一个问题(即使有内部故障,也应该正确地报告)。检查它是否与包的最新版本一起工作。你的
lyricsgenius.__version__
是什么?最近的版本似乎是3天前才创建的1.6.0。尝试手动安装(pip install lyricsgenius
)。如果问题仍然存在,请查看官方存储库以获取详细联系信息。Python Package Index将您发送到https://github.com/johnwmillr/LyricsGenius/issues。该项目的自述文件说“只需打开一个问题”。
相关问题 更多 >
编程相关推荐