为了简单起见,假设我想搜索碧昂斯1000次
artist_name_list = []
for i in np.arange (0, 1000, 1):
searchResults = sp.search("beyonce",1,0,"artist")
artist = searchResults['artists']['items'][0]
artist_name = artist['name']
artist_name_list.append(artist_name)
当我运行这个程序时,我在看似随机的点上得到了一个404错误,我可以判断出来,因为每次运行len(artist_name_list(时都会有所不同。
HTTP Error for GET to https://api.spotify.com/v1/search with Params: {'q': 'beyonce', 'limit': 1, 'offset': 0, 'type': 'artist', 'market': None} returned 404 due to None
有人能帮我了解一下发生了什么吗?它似乎在当天早些时候运行。
谢谢!
我唯一能想到的是,你对API的使用有一些限制,也许可以尝试在API请求之间插入暂停,例如使用time.sleep:
import time
time.sleep(5) # waits for 5 seconds