簡體   English   中英

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;

?>

結果的輸出類似於“未找到結果”

有任何想法嗎?

Google對向其發送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 );

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM