ありがとう。幸いなことに、Atacのベータ版のWebサイトはhttp://beta.muovi.roma.itにあり、エラーメッセージがはるかに優れているため、新しいバージョンでもエージェントが必要であることが私の要求に明確に示されています。1つ提供すると、ベータ版とメインバージョンの両方が正しく解析されました。これが関連するコードです。
$someUA = array (
"Mozilla/5.0 (Windows; U; Windows NT 6.0; fr; rv:1.9.1b1) Gecko/20081007 Firefox/3.1b1",
"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.0",
"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Chrome/0.4.154.18 Safari/525.19",
"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.149.27 Safari/525.13",
"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30)",
"Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.40607)",
"Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1; .NET CLR 1.1.4322)",
"Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1; .NET CLR 1.0.3705; Media Center PC 3.1; Alexa Toolbar; .NET CLR 1.1.4322; .NET CLR 2.0.50727)",
"Mozilla/45.0 (compatible; MSIE 6.0; Windows NT 5.1)",
"Mozilla/4.08 (compatible; MSIE 6.0; Windows NT 5.1)",
"Mozilla/4.01 (compatible; MSIE 6.0; Windows NT 5.1)"
);
function getRandomUserAgent() {
srand((double)microtime()*1000000);
global $someUA;
return $someUA[rand(0,count($someUA)-1)];
}
function atac_get_html($url, $language){
//$url='http://muovi.roma.it/paline/palina/77113?nav=4'; //manual forcing
set_include_path("/iPhone/simplehtmldom_1_5");
require_once('simple_html_dom.php');
require_once('atacurl.php');
// Create DOM from URL or file
//$atacurl=atacurl();
//$languageUrl=$atacurl."/lingua/set/".$language;
$languageUrl="http://muovi.roma.it/lingua/set/en";
if (!isset($_SESSION['ckfile'])) {
$ckfile = tempnam ("/tmp", "CURLCOOKIE");
$_SESSION['ckfile']=$ckfile;
/* STEP 2. visit the homepage to set the cookie properly */
$ch = curl_init ($languageUrl);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $ckfile);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_USERAGENT, getRandomUserAgent());
$output = curl_exec ($ch);
}
}
$ckfile=$_SESSION['ckfile'];
/* STEP 3. visit cookiepage.php */
$ch = curl_init ($url);
curl_setopt ($ch, CURLOPT_COOKIEFILE, $ckfile);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERAGENT, getRandomUserAgent());
$output = curl_exec ($ch);
curl_close( $ch );
return str_get_html($output);
}