關鍵是要在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.xianlaiwan.cn/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.xianlaiwan.cn/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 protected](你的賬號)&password=xxxxx(你的密碼)&remember=1';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.xianlaiwan.cn");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
date_default_timezone_set('PRC');
(1)
$data = '[email protected](你的賬號)&password=xxxxx(你的密碼)&remember=1';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.xianlaiwan.cn");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
date_default_timezone_set('PRC');
2016-03-17