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
