【问题标题】:Is it possible to get scrobbles and listeners from the Last.FM API?是否可以从 Last.FM API 中获取 scrobbles 和 listeners?
【发布时间】:2013-05-24 18:55:34
【问题描述】:
我正在使用 Python 在 Artists 中收集信息。
在其他来源中,我想使用 Last.FM 获取有关每个艺术家的 Scrobbles 和 Listeners 的信息。
谁能告诉我这是否可以通过 API 实现,或者我是否应该尝试一下 BeautifulSoup 并解析 HTML?
我已经在使用 Python 的 pylast 模块,但不知道它应该如何工作。
【问题讨论】:
标签:
python
web-scraping
web-crawler
last.fm
【解决方案1】:
以下是使用 pylast 的方法:
#!/usr/bin/env python
import pylast
# You have to have your own unique two values for API_KEY and API_SECRET
# Obtain yours from http://www.last.fm/api/account for Last.fm
API_KEY = "TODO_ENTER_YOURS"
API_SECRET = "TODO_ENTER_YOURS"
lastfm_network = pylast.LastFMNetwork(api_key = API_KEY, api_secret = API_SECRET)
artist = lastfm_network.get_artist("Test Artist")
print "Listeners:", artist.get_listener_count()
print "Scrobbles:", artist.get_playcount()
输出:
Listeners: 851
Scrobbles: 3434