使用PHP HTML Parser在Explore页面获取“Trending Music”

时间:2014-08-14 15:53:34

标签: php html html-parsing soundcloud

我试图从SoundCloud的探索页面获取歌曲以获得"趋势音乐"。我有一个PHP脚本,它从探索页面获取内容。

我正在使用" PHP Simple HTML DOM Parser" (http://simplehtmldom.sourceforge.net/)。我修改了我的请求并将我的用户代理设置为最新的Firefox用户代理。

看起来像这样:

$opts = array(
    'http'=>array(
    'method'=>"GET",
    'header'=>"Accept-language: en\r\n" .
          "Cookie: foo=bar\r\n".
          "User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0"
    )
);
$context = stream_context_create($opts);
$html = file_get_contents('https://www.soundcloud.com/explore/',false,$context);

但现在我从SoundCloud获得错误页面说:"抱歉!我们无法找到该页面。" 当我直接在浏览器中打开该URL时,它可以工作。我认为有些javascript正在获取实际数据,有人可以帮我吗?

0 个答案:

没有答案
相关问题