当前位置:首页 » 操作系统 » https源码

https源码

发布时间: 2023-10-28 22:03:18

‘壹’ 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

热点内容
随机启动脚本 发布:2025-07-05 16:10:30 浏览:516
微博数据库设计 发布:2025-07-05 15:30:55 浏览:19
linux485 发布:2025-07-05 14:38:28 浏览:299
php用的软件 发布:2025-07-05 14:06:22 浏览:751
没有权限访问计算机 发布:2025-07-05 13:29:11 浏览:425
javaweb开发教程视频教程 发布:2025-07-05 13:24:41 浏览:687
康师傅控流脚本破解 发布:2025-07-05 13:17:27 浏览:234
java的开发流程 发布:2025-07-05 12:45:11 浏览:680
怎么看内存卡配置 发布:2025-07-05 12:29:19 浏览:277
访问学者英文个人简历 发布:2025-07-05 12:29:17 浏览:828