關鍵是要在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
(5)
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);// post數據
curl_setopt($curl, CURLOPT_POST, 1);// 請求數據
curl_setopt($curl, CURLOPT_POSTFIELDS, $post);// 是否抓取跳轉后的頁面
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
$response = curl_exec($curl);
curl_close($curl);
$xml = simplexml_load_string($response);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);// post數據
curl_setopt($curl, CURLOPT_POST, 1);// 請求數據
curl_setopt($curl, CURLOPT_POSTFIELDS, $post);// 是否抓取跳轉后的頁面
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
$response = curl_exec($curl);
curl_close($curl);
$xml = simplexml_load_string($response);
2016-03-17
(4)
$header[] = 'Upgrade-Insecure-Requests: 1';
$header[] = 'User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36';
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
// 不輸出header頭信息
curl_setopt($curl, CURLOPT_HEADER, 0);
// 保存到字符串而不是輸出
$header[] = 'Upgrade-Insecure-Requests: 1';
$header[] = 'User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36';
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
// 不輸出header頭信息
curl_setopt($curl, CURLOPT_HEADER, 0);
// 保存到字符串而不是輸出
2016-03-17
(3)
$header[] = 'Content-Type: application/x-www-form-urlencoded';
$header[] = 'Host: www.webxml.com.cn';
$header[] = 'Origin: http://www.webxml.com.cn';
$header[] = 'Proxy-Connection: keep-alive';
$header[] = 'Referer: http://www.webxml.com.cn/WebServices/WeatherWS.asmx?op=getWeather';
$header[] = 'Content-Type: application/x-www-form-urlencoded';
$header[] = 'Host: www.webxml.com.cn';
$header[] = 'Origin: http://www.webxml.com.cn';
$header[] = 'Proxy-Connection: keep-alive';
$header[] = 'Referer: http://www.webxml.com.cn/WebServices/WeatherWS.asmx?op=getWeather';
2016-03-17
(2)
$header[] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8';
$header[] = 'Accept-Encoding: gzip, deflate';
$header[] = 'Accept-Language: zh-CN,zh;q=0.8';
$header[] = 'Cache-Control: max-age=0';
$header[] = 'Content-Length: '.strlen($post);
$header[] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8';
$header[] = 'Accept-Encoding: gzip, deflate';
$header[] = 'Accept-Language: zh-CN,zh;q=0.8';
$header[] = 'Cache-Control: max-age=0';
$header[] = 'Content-Length: '.strlen($post);
2016-03-17
按教程重新寫了下代碼,老師的教程是2014年的,可能有部分同學會跟著老師寫,卻發現沒有任何結果,試試我下面的代碼吧
(1)
$post='theCityCode='.urlencode('杭州').'&theUserID=';// 初始化
$curl = curl_init('http://ws.webxml.com.cn/WebServices/WeatherWS.asmx/getWeather');
$header = array();
(1)
$post='theCityCode='.urlencode('杭州').'&theUserID=';// 初始化
$curl = curl_init('http://ws.webxml.com.cn/WebServices/WeatherWS.asmx/getWeather');
$header = array();
2016-03-17
不太理解ftp的用戶名和密碼設定
但是理解 $data = '[email protected]&password=123qwe&remember=1';
現在的慕課網版本不能這么寫
應該這么寫 $data = '[email protected]&password=123qwe&remember=1';
但是理解 $data = '[email protected]&password=123qwe&remember=1';
現在的慕課網版本不能這么寫
應該這么寫 $data = '[email protected]&password=123qwe&remember=1';
2016-03-15