当我在网络浏览器中访问http://musicbrainz.org/ws/2/artist/?query=artist:Sun+Ra时,我得到了我期待的响应。
但是当我
require(httr)
GET('http://musicbrainz.org/ws/2/artist/?query=artist:Sun+Ra') -> sun.ra
content(sun.ra)
>>> NULL
响应正文为空,即使sun.ra
获得状态200:
Response [http://musicbrainz.org/ws/2/artist/?query=artist:Sun+Ra]
Date: 2014-10-11 17:26
Status: 200
Content-type: application/json; charset=utf-8
<EMPTY BODY>
httr
是否有&#34;裸体&#34; XML响应?
此XML文件似乎没有与之关联的任何样式信息。
(我实际上认为我已经找到了答案,但仍然会发布问题并回答自己,以防其他人以后遇到同样的问题......)
答案 0 :(得分:1)
这不是XML的问题。即使MusicBrainz不需要API密钥,您也需要为服务标识自己。使用RCurl
:
require(RCurl)
getURL('http://musicbrainz.org/ws/2/artist/?query=artist:Sun+Ra'
[1] "<?xml version=\"1.0\" encoding=\"UTF-8\"?><error><text>Your requests are
being throttled by MusicBrainz because the application you are using
has not identified itself.
Please update your application, and see http://musicbrainz.org/doc/XML_Web_Service/Rate_Limiting for more information.</text><text>For usage, please see: http://musicbrainz.org/development/mmd</text></error>"