2012-04-02 8 views
0

私はhttp://gmmobile.atm-mi.it/wsbw/InfoTraffico/ページを認証しないと解析したいと思います。しかし、私はその内容を解析するために、PHPスクリプトを介してアクセスしようとすると、私はエラーが表示されます。PHPスクリプトからページにアクセスすると面白い500エラー

Warning: file_get_contents(http://gmmobile.atm-mi.it/wsbw/InfoTraffico/) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error in /iPhone/simplehtmldom_1_5/simple_html_dom.php on line 70

私が使用していたコードは以下の通りです:

かもしれない何
include('simple_html_dom.php'); 
// Create DOM from URL or file 
$url='http://gmmobile.atm-mi.it/wsbw/InfoTraffico/'; 
echo $url; 
$html = file_get_html($url); 
echo $html; 
$i=0; 
foreach($html->find('option') as $content) 
{ 
    $linea=$content->value; 
    $destination=$content->title; 
     $i++; 

} 

問題とはどのように私はそれを修正することができますか?

答えて

0

は、ユーザエージェントを追加してください:

$url = 'http://gmmobile.atm-mi.it/wsbw/InfoTraffico/'; 
$options = array('http' => array('header' => "User-Agent: myFooAgent\r\n")); 
$context = stream_context_create($options); 
echo file_get_contents($url, false, $context); 
+0

おかげで、私は提案を見ているだろう。 –

+0

すぐに実装してくれてありがとうと申し訳ありませんが、私は他の問題を修正しなければなりませんでした。 –

+0

質問を閉じる必要があります。 –

関連する問題