https源碼
『壹』 php怎麼抓取這個鏈接https://locate.apple.com/cn/zh/service/pt=3&lat=23.134521&lon=113.358803的源碼
<?php
function dg_string($data,$flagA, $flagB, $start = 0){//配套截取字元串
	$flagAL=strlen($flagA);
	$flagBL=strlen($flagB);
	$rn='';
	$a=$b=0;
	if(($findA=strpos($data,$flagA, $start))!==false){
		$a=1;
		$tmpA=$findA;
		$findB=$findA+$flagAL;
		$findA=$findB;
		while($a!=$b){
			if(($findB = strpos($data, $flagB, $findB))!==false){
				$b++;
				if(($findA = strpos($data, $flagA, $findA))!==false){
					if($findA>$findB){
						if($a==$b){
							//結束
							$findB+=$flagBL;
							$rn=substr($data,$tmpA,$findB-$tmpA);
						} else {
							$a++;
							$findB=$findA+$flagAL;
							$findA=$findB;
						}
					} else {
						$a++;
						$findA+=$flagAL;
						$findB+=$flagBL;
					}
				} else {
					if($a==$b){
						//結束
						$findB+=$flagBL;
						$rn=substr($data,$tmpA,$findB-$tmpA);
					} else {
						//標記不完整
						$findB+=$flagBL;
					}
				}
			} else {
				//標記不完整
				$rn=substr($data,$tmpA);
				$rn.=str_repeat($flagB,$a-$b);
				break;
			}
		}
	}
	return $rn;
}
$html = file_get_contents('https://locate.apple.com/cn/zh/service/?pt=3&lat=23.134521&lon=113.358803');//獲取源碼
$find  = strpos($html, 'window.resourceLocator.setup');
$json1 = dg_string($html, '{', '}', $find);//獲取第一個JSON數據
$find  = strpos($html, 'window.resourceLocator.storeSetup');
$json2 = dg_string($html, '{', '}', $find);//獲取第二個JSON數據
$arr1  = json_decode($json1, true);//第一個JSON數據轉為數組
$arr2  = json_decode($json2, true);//第二個JSON數據轉為數組
print_r($arr1);
print_r($arr2);
//得到了數組,你想獲取哪個參數都行了,你自己看著辦吧,樓主可親測代碼
?>
『貳』 https訪問php直接顯示源碼是什麼問題
HTTPS配置錯誤,導致的環境沒有正常顯示,請重新配置。
配置教程:https://www.gworg.com/ssl/127.html
