我需要用PHP从grooveshark URL中抓取歌曲信息:
http://grooveshark.com/s/Soul+Meets+Body/4s4DZd?src=5有没有办法不使用API,或者我需要Grooveshark API?
谢谢
发布于 2012-02-14 04:48:20
看起来这个URL在你访问之后会重定向到http://grooveshark.com/#!/s/Soul+Meets+Body/4s4DZd?src=5,但是在此之前的源代码确实有一些用HTML5 Microdata编码的信息(我相信你会发现一些easier to read resources )。
在源代码中:
<div itemscope itemtype="http://www.schema.org/MusicRecording">
<img src="http://images.grooveshark.com/static/amazonart/s1085803.png" alt="Plans by Death Cab for Cutie" title="Plans by Death Cab for Cutie" itemprop="image" />
<div>
<span itemprop="name">Soul Meets Body</span>
by
<span itemprop="byArtist" itemscope itemtype="http://www.schema.org/MusicGroup">
<a href="http://grooveshark.com/artist/Death+Cab+For+Cutie/401368"><span itemprop="name">Death Cab for Cutie</span></a>
<meta content="http://grooveshark.com/artist/Death+Cab+For+Cutie/401368" itemprop="url" />
</span>
on
<span itemprop="inAlbum" itemscope itemtype="http://www.schema.org/MusicAlbum">
<a href="http://grooveshark.com/album/Plans/1085803"><span itemprop="name">Plans</span></a>
<meta content="http://grooveshark.com/album/Plans/1085803" itemprop="url" />
</span>
</div>
</div>你可以使用PHP的DomDocument或者其他的超文本标记语言解析器来获取这些信息,但是我可以想象使用他们的API会更容易。
https://stackoverflow.com/questions/9266478
复制相似问题