当前位置:首页 » 操作系统 » 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

热点内容
java返回this 发布:2025-10-20 08:28:16 浏览:581
制作脚本网站 发布:2025-10-20 08:17:34 浏览:875
python中的init方法 发布:2025-10-20 08:17:33 浏览:569
图案密码什么意思 发布:2025-10-20 08:16:56 浏览:754
怎么清理微信视频缓存 发布:2025-10-20 08:12:37 浏览:672
c语言编译器怎么看执行过程 发布:2025-10-20 08:00:32 浏览:999
邮箱如何填写发信服务器 发布:2025-10-20 07:45:27 浏览:242
shell脚本入门案例 发布:2025-10-20 07:44:45 浏览:102
怎么上传照片浏览上传 发布:2025-10-20 07:44:03 浏览:794
python股票数据获取 发布:2025-10-20 07:39:44 浏览:699