0
我試圖讓一個頁面的內容是這樣的:的http_access返回(也simple_html_dom)
<?php
include_once 'simple_html_dom.php';
$opts = array('http' =>
array(
'method' => 'GET',
'timeout' => 10
)
);
$domain = "http://www.esperandoaramon.com";
//$domain = "http://www.google.com";
$context = stream_context_create($opts);
$input = @file_get_contents($domain,false,$context) or die("Could not access file: $domain");
echo($input);
?>
我能得到www.google.com內容這樣,不幸的是,其他域只給我這個通知:
Notice:
Text: Undefined index: HTTP_ACCEPT
File: /home/trdeport/public_html/esperandoaramon/_visit.php
Line: 4
這HTTP_ACCEPT正在殺我......該頁面在瀏覽器上完美運行。有什麼解決方法嗎?
非常感謝pilsetnieks!就像一個魅力^^ – vivoconunxino 2013-04-26 20:41:16
我終於不得不添加下面的解釋:'header'=>「Accept:text/html \ r \ n」。 「User-Agent:Mozilla/5.0(X11; Linux x86_64; rv:12.0)Gecko/20100101 Firefox/12.0」 – vivoconunxino 2013-04-26 20:42:14