关键是要在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
(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 = 'username=demo_peter@126.com&password=123qwe&remember=1';
现在的慕课网版本不能这么写
应该这么写 $data = 'email=demo_peter@126.com&password=123qwe&remember=1';
但是理解 $data = 'username=demo_peter@126.com&password=123qwe&remember=1';
现在的慕课网版本不能这么写
应该这么写 $data = 'email=demo_peter@126.com&password=123qwe&remember=1';
2016-03-15