我正在尝试编写一个 python 脚本来对 Last.fm 进行查询,但我不断收到返回的无效方法错误。
我不希望链接到预先编写的 last.fm python 库,我试图将其作为“测试我所知道的”类型的项目。提前致谢!
import urllib
import httplib
params = urllib.urlencode({'method' : 'artist.getsimilar',
'artist' : 'band',
'limit' : '5',
'api_key' : #API key goes here})
header = {"user-agent" : "myapp/1.0"}
lastfm = httplib.HTTPConnection("ws.audioscrobbler.com")
lastfm.request("POST","/2.0/?",params,header)
response = lastfm.getresponse()
print response.read()