有关采集的问题,可以帮我调试一下吗?修改成登录并可采集,我要在虚拟服务器上运行
我看有个网友的代码很简快
我是学ASP的,调试PHP实在是不行
 
Go_Rush网友的代码
<?// 这段代码是运行在命令行模式的.
$ua='Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)';
$downlod_path="F:\\";     // 下载文件保存目录
$cookie_file="cookie.dat";
$loginpost='user=dullwolf&pass=123456&CkiExp=-1&submitflag=ddddls-%2B%2B%2B&regbtn.x=50&regbtn.y=31';
$login_url='http://club.joyes.com/User/Login.asp';
$jar_url="http://sou.joyes.com/game_down.aspx?type=gam&id=";
$idlist=array(55397,55409,55387);   //要下多少文件这里自己加function curl_gorush($id=''){
global $cookie_file,$ua,$downlod_path,$loginpost,$login_url,$jar_url;
echo   $id==='' ? "正在登陆...\n" : "正在下载文件\tid=$id\n";
$ch = curl_init();
$url= $id===''?$login_url:$jar_url.$id;
curl_setopt($ch, CURLOPT_URL,$url );
curl_setopt($ch, CURLOPT_REFERER, $url); 
curl_setopt($ch, CURLOPT_USERAGENT,$ua);
curl_setopt($ch, CURLOPT_COOKIEFILE,$cookie_file);    
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);    
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); if ($id===''){
curl_setopt($ch, CURLOPT_POST, 1);      
curl_setopt($ch, CURLOPT_POSTFIELDS,$loginpost);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);   
$content=curl_exec($ch);
curl_close ($ch);
return !empty($content) && strpos($content,"登陆成功")!==false;
}else{
$fp=fopen($downlod_path.$id.'.jar','wb');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_exec($ch);
curl_close ($ch);
fclose($fp);
}
}
if (!extension_loaded('curl')) dl("php_curl." . PHP_SHLIB_SUFFIX);
curl_gorush()?array_walk($idlist,'curl_gorush'):die("登陆失败\n");
?>
复制上面的代码保存到 x:\xxx\xxxxxx.php然后建立一个批处理文件 run.bat (run.bat放哪个目录都可以)
内容如下: 假设你的php安装在D盘d:\your_php.exe_path\php.exe x:\xxx\xxxxxx.php
pause
双击 run.bat 运行, 哈哈,下载的那三个 jar文件乖乖的躺在 F:\了