PHP服务器点击 https://www.google.com/movies 没有得到任何结果


PHP server hitting https://www.google.com/movies gets no results

如果你去 https://www.google.com/movies?near=02215&q=revenant 你会清楚地得到可以解析的结果。但是,当我将一个小脚本上传到我的服务器时,例如:

<?php 
$string = file_get_contents("https://www.google.com/movies?near=02215&q=revenant");
echo $string;
?>
结果

的输出类似于"未找到结果"

有什么想法吗?

谷歌对他们向谁发送HTTP响应很挑剔,告诉他们你是一个浏览器,看看这是否有效:

$context = stream_context_create(array(
    'http' => array(
        'method' => "GET",
        'header' => "" .
            "Accept: text/html" . "'r'n" .
            "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0" . "'r'n"
    )
));
$string = file_get_contents( "https://www.google.com/movies?near=02215&q=revenant", false, $context );