采集程序登录成功~~可是COOKIES没有写入成文本
cookes.txt 文件没有值
如何要把这次登录的COOKIES的值,提出来
<?php
$cookie_jar = 'cookie.txt';
$data = array('mvfAdminMonths' => '200706',
'mvfSiteProvinces' => 'Beijing',
'whichFirst' => 'AS',
'__act' => '__id.22.SeatsQuery.adp.actList',
'submit.x'=> '28',
'submit.y'=> '9');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'http://toefl.etest.edu.cn/cn/SeatsQuery');
curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_jar);
//echo curl_exec($ch);
$contents= curl_exec($ch);//写入成文本
$file_name="dada.txt";
$handle = @fopen($save_path.$file_name,"w+");
if ($handle)
{
if (@fwrite($handle,$contents))
{
return 1;
}else
{
//写入文件错误
return -3;
}
}else
{
//文件不可写
return -4;
}
?>
cookes.txt 文件没有值
如何要把这次登录的COOKIES的值,提出来
<?php
$cookie_jar = 'cookie.txt';
$data = array('mvfAdminMonths' => '200706',
'mvfSiteProvinces' => 'Beijing',
'whichFirst' => 'AS',
'__act' => '__id.22.SeatsQuery.adp.actList',
'submit.x'=> '28',
'submit.y'=> '9');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'http://toefl.etest.edu.cn/cn/SeatsQuery');
curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_jar);
//echo curl_exec($ch);
$contents= curl_exec($ch);//写入成文本
$file_name="dada.txt";
$handle = @fopen($save_path.$file_name,"w+");
if ($handle)
{
if (@fwrite($handle,$contents))
{
return 1;
}else
{
//写入文件错误
return -3;
}
}else
{
//文件不可写
return -4;
}
?>
设置PHP的open_basedir 了吗?
<?php
echo phpinfo();
?>
查看open_basedir
如果已经设置,那么检测当前目录是否允许 运行Web Server 的用户去写呢?
如果不行,设置当前目录 为 777 ,试试看。