从php脚本访问页面时出现有趣的500错误


Funny 500 error when accessing page from php script

我想解析http://gmmobile.atm-mi.it/wsbw/InfoTraffico/不需要身份验证的页面。然而,当我试图通过PHP脚本访问它以解析其内容时,我收到了一个错误:

警告:file_get_contents(http://gmmobile.atm-mi.it/wsbw/InfoTraffico/)[函数.file获取内容]:无法打开流:HTTP请求失败!HTTP/1.1 500内部服务器错误,在第70行的/iPhone/simplehtmldom_1_5/simple_html_dom.php 中

我使用的代码如下:

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++;
}

可能是什么问题?我该如何解决?

尝试添加用户代理:

$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);