當前位置:首頁 » 操作系統 » 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

熱點內容
vba獲取網頁表格資料庫資料庫資料庫 發布:2024-05-18 12:23:24 瀏覽:699
騰訊伺服器為什麼卡頓 發布:2024-05-18 12:02:12 瀏覽:305
如何知道密碼鎖有沒有nfc 發布:2024-05-18 11:58:09 瀏覽:961
單片機c語言模塊化編程 發布:2024-05-18 11:53:16 瀏覽:644
win7xp共享列印機拒絕訪問 發布:2024-05-18 11:51:00 瀏覽:847
zkeys金屬伺服器怎麼使用 發布:2024-05-18 11:49:31 瀏覽:581
電信路由器密碼設置無線路由器怎麼設置密碼 發布:2024-05-18 10:55:00 瀏覽:647
安卓系統是屬於哪個國家的手機 發布:2024-05-18 10:41:41 瀏覽:99
linux運維前景 發布:2024-05-18 10:24:44 瀏覽:658
c語言crc演算法 發布:2024-05-18 09:59:03 瀏覽:644