关键是要在header里加上这个 'User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36'
2016-03-17
(5)
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-type: text/xml"));
$output = curl_exec($ch);
curl_close($ch);
echo $output;
把上面1.2.3.4.5合起来,就ok啦~试试吧~
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-type: text/xml"));
$output = curl_exec($ch);
curl_close($ch);
echo $output;
把上面1.2.3.4.5合起来,就ok啦~试试吧~
2016-03-17
(4)
curl_setopt($ch, CURLOPT_HTTPHEADER, array("application/x-www-form-urlencoded;charset=utf-8","Content-Length: " . strlen($data)));
curl_exec($ch);
curl_setopt($ch, CURLOPT_URL, "http://www.imooc.com/space/index");
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("application/x-www-form-urlencoded;charset=utf-8","Content-Length: " . strlen($data)));
curl_exec($ch);
curl_setopt($ch, CURLOPT_URL, "http://www.imooc.com/space/index");
curl_setopt($ch, CURLOPT_POST, 0);
2016-03-17
(3)
curl_setopt($ch, CURLOPT_COOKIE, session_name(). '=' . session_id());
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_COOKIE, session_name(). '=' . session_id());
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
2016-03-17
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); //不使用认证
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); //不使用认证
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookiefile");
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookiefile");
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); //不使用认证
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookiefile");
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookiefile");
2016-03-17
老师的教程是2014年的,新写了下代码,用的是首页的登录,不是老师以前版本的慕课网的登录地址,欢迎参考
(1)
$data = 'email=xxxxxx@xx.xxx(你的账号)&password=xxxxx(你的密码)&remember=1';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.imooc.com");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
date_default_timezone_set('PRC');
(1)
$data = 'email=xxxxxx@xx.xxx(你的账号)&password=xxxxx(你的密码)&remember=1';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.imooc.com");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
date_default_timezone_set('PRC');
2016-03-17