百度出現(xiàn)網(wǎng)頁(yè)重定向,估計(jì)老師后面會(huì)講到吧
2016-09-21
哇,學(xué)習(xí)好多,記住常用的curl_setopt參數(shù)即可,還有curl的其他方法
2016-09-01
我發(fā)現(xiàn)CURLOPT_HTTPHEADER發(fā)送header頭信息,不設(shè)置,請(qǐng)求時(shí)也會(huì)自動(dòng)生成頭部信息,不影響請(qǐng)求數(shù)據(jù)
2016-08-30
$xml = simplexml_load_string($tmp);
//echo $xml->string[11];
$array = array(
'0'=>'省份',
'1'=>'城市',
'2'=>'經(jīng)緯度',
'3'=>'天氣圖片',
'4'=>'時(shí)間',
'5'=>'溫度'
);
//print_r($xml->string);
foreach ($array as $key => $value) {
echo $value.":".$xml->string[$key]."<br/>";
}
//echo $xml->string[11];
$array = array(
'0'=>'省份',
'1'=>'城市',
'2'=>'經(jīng)緯度',
'3'=>'天氣圖片',
'4'=>'時(shí)間',
'5'=>'溫度'
);
//print_r($xml->string);
foreach ($array as $key => $value) {
echo $value.":".$xml->string[$key]."<br/>";
}
2016-08-30
把獲取的結(jié)果用simplexml_load_string轉(zhuǎn)換成迭代對(duì)象后,可以用下面的方式獲取指定數(shù)據(jù)
$xml = simplexml_load_string($tmp);
echo $xml->string[11];
$xml = simplexml_load_string($tmp);
echo $xml->string[11];
2016-08-30
單色彩虹的答案比較完整,但做到獲取結(jié)果只需要
$post = 'theCityCode=' . urlencode('杭州') . '&theUserID='; //post數(shù)據(jù)
$curl = curl_init();
$header[] = 'User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36';
$post = 'theCityCode=' . urlencode('杭州') . '&theUserID='; //post數(shù)據(jù)
$curl = curl_init();
$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-08-10
curl_setopt($curl, CURLOPT_HTTPHEADER, $header); //curl_opt_http_header包裝請(qǐng)求頭
curl_setopt($curl, CURLOPT_URL, 'http://ws.webxml.com.cn/WebServices/WeatherWS.asmx/getWeather');
curl_setopt($curl, CURLOPT_URL, 'http://ws.webxml.com.cn/WebServices/WeatherWS.asmx/getWeather');
2016-08-10
curl_setopt($curl, CURLOPT_HEADER, 0); //如果你想把一個(gè)頭包含在輸出中,設(shè)置這個(gè)選項(xiàng)為一個(gè)非零值。
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); //結(jié)果緩存,不直接輸出
curl_setopt($curl, CURLOPT_POST, 1); //設(shè)置為post請(qǐng)求,否則默認(rèn)為get
curl_setopt($curl, CURLOPT_POSTFIELDS, $post); //post的數(shù)據(jù)
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); //結(jié)果緩存,不直接輸出
curl_setopt($curl, CURLOPT_POST, 1); //設(shè)置為post請(qǐng)求,否則默認(rèn)為get
curl_setopt($curl, CURLOPT_POSTFIELDS, $post); //post的數(shù)據(jù)
2016-08-10
$response = curl_exec($curl);
curl_close($curl);
$xml = simplexml_load_string($response);
print_r($xml);
curl_close($curl);
$xml = simplexml_load_string($response);
print_r($xml);
2016-08-10
請(qǐng)求頭里需要偽裝成瀏覽器,
$header[] = 'User-Agent: xx';
$header[] = 'User-Agent: xx';
2016-08-10