PHP-twitch.tv获取页面内容
我使用PHP curl从twitch.tv获取页面内容,进行一些必要的检查。PHP-twitch.tv获取页面内容,php,curl,get,Php,Curl,Get,我使用PHP curl从twitch.tv获取页面内容,进行一些必要的检查。 twitch.tv似乎做了一些更改,现在没有内容通过PHP curl返回 我现在应该怎么做才能通过php获取内容 我在脚本上使用了以下函数,但没有返回响应 function get_web_page($url) { $options = array( CURLOPT_RETURNTRANSFER => true, // return web page
twitch.tv似乎做了一些更改,现在没有内容通过PHP curl返回 我现在应该怎么做才能通过php获取内容 我在脚本上使用了以下函数,但没有返回响应
function get_web_page($url) {
$options = array(
CURLOPT_RETURNTRANSFER => true, // return web page
CURLOPT_HEADER => false, // don't return headers
CURLOPT_FOLLOWLOCATION => true, // follow redirects
CURLOPT_MAXREDIRS => 10, // stop after 10 redirects
CURLOPT_ENCODING => "", // handle compressed
CURLOPT_USERAGENT => "test", // name of client
CURLOPT_AUTOREFERER => true, // set referrer on redirect
CURLOPT_CONNECTTIMEOUT => 30, // time-out on connect
CURLOPT_TIMEOUT => 120, // time-out on response
);
$ch = curl_init($url);
curl_setopt_array($ch, $options);
$content = curl_exec($ch);
curl_close($ch);
return $content;
}
// $url_final = something from twitch.tv
$response = get_web_page($url_final);
echo $response;
“看来twitch.tv做了一些改变”。你看过他们改变了什么吗?你想获取什么url?我可以把它取出来,没有任何问题。哦,对不起,描述不正确,我意识到它更好。我需要返回$response,完整的源代码twitch.tv页面正在返回。这意味着我还需要通过javascript加载的代码。我找到了关于phantomjs的资料,但据我所知,它需要在服务器上安装一些特殊的东西吗?你知道如何利用php的集成功能实现同样的功能吗?(也可以获取通过javascript加载的代码)。当做