v2.5.2
Giriş yap

.json çıktının sonundaki html etiketlerini silme

g4rymckinn0n
380 defa görüntülendi

Merhaba,
Elimde sorgu gönderdiğim json çıktısı olan bir sayfa var. Sayfa içeriği json fakat formatı html kalıntıları içeriyor.

Sayfanın sonundaki etiketler şu şekilde: http://prntscr.com/26skp7s

buradan veri alamıyorum. sanırım bu iki etiket yüzünden. sayfanın gerisi tamamen json formatında.

buradaki veriyi alıp kendi json dosyama yazdırıyorum. fakat html ve body etiketleri de geliyor. Bu etiketleri hariç bırakarak json dosyama yazdırmak istiyorum. Bunu nasıl yapabilirim?

g4rymckinn0n
1017 gün önce

Öncelikle yanıt için çok teşekkür ederim.

Bu konuda yaptığım araştırmaların tamamı str_teplace ve preg_replace ile çözülür diyor senin de dediğin gibi.

Ben şu şekilde deniyorum:

$file = file_get_contents('http://prntscr.com/26subcm'); //veriyi çektiğim yerdeki durum linkte

echo $file['ALTIN']['alis']; // çıktıda sadece bu var : http://prntscr.com/26sudlg
echo $file; // bu şekilde denersem aşağıdaki kaynak kodu gibi yazdırıyor. json görünümlü HTML sanırım. Sondaki etiketleri silsem buradaki veriyle işlem yapabileceğim ama oradaki html body sanırım işi bozuyor.

aşağıdaki çıktıyı bir .html dosyasına yazdırıp o dosya üzerinden file_get_contents ile replace etmeye çalışır ve sonuç alırsanız çözüme kavuşmuş olurum.

verinin geldiği sayfanın kaynak kodu ise şu şekilde:

{"meta":{"time":1644481669858,"time_formatted":"","fiyat_yayini":"web_socket","fiyat_guncelleme":2000},"data":{"USDTRY":{"code":"USDTRY","alis":"13.5360","satis":"13.5520","tarih":"10-02-2022 11:27:49","dir":{"alis_dir":"","satis_dir":""},"dusuk":13.533,"yuksek":13.604,"kapanis":13.518},"ALTIN":{"code":"ALTIN","alis":"798.410","satis":"800.470","tarih":"10-02-2022 11:27:49","dir":{"alis_dir":"","satis_dir":""},"dusuk":"800.370","yuksek":804.53,"kapanis":797.1},"OMRUSD":{"code":"OMRUSD","alis":2.503,"satis":2.583,"tarih":"10-02-2022 11:15:01","dir":{"alis_dir":"up","satis_dir":"up"},"dusuk":2.583,"yuksek":2.583,"kapanis":2.503},"USDPURE":{"code":"USDPURE","alis":"58980.0000","satis":"59070.0000","tarih":"10-02-2022 11:27:44","dir":{"alis_dir":"","satis_dir":""},"dusuk":59040,"yuksek":59180,"kapanis":58960},"EURTRY":{"code":"EURTRY","alis":"15.4460","satis":"15.4880","tarih":"10-02-2022 11:27:47","dir":{"alis_dir":"down","satis_dir":""},"dusuk":15.453,"yuksek":15.542,"kapanis":15.42},"ONS":{"code":"ONS","alis":"1832.30","satis":"1832.60","tarih":"10-02-2022 11:27:44","dir":{"alis_dir":"","satis_dir":"down"},"dusuk":1831.8,"yuksek":1836,"kapanis":1833},"USDRUB":{"code":"USDRUB","alis":"74.2160","satis":"76.7360","tarih":"10-02-2022 11:27:49","dir":{"alis_dir":"","satis_dir":""},"dusuk":76.63,"yuksek":76.823,"kapanis":74.107},"EURUSD":{"code":"EURUSD","alis":1.1411,"satis":1.1428,"tarih":"10-02-2022 11:27:47","dir":{"alis_dir":"down","satis_dir":""},"dusuk":1.1411,"yuksek":1.1433,"kapanis":1.1407},"USDKG":{"code":"USDKG","alis":"58690.0","satis":"58770.0","tarih":"10-02-2022 11:27:44","dir":{"alis_dir":"","satis_dir":""},"dusuk":58740,"yuksek":58880,"kapanis":58670},"USDBGN":{"code":"USDBGN","alis":1.4628,"satis":1.9628,"tarih":"10-02-2022 11:15:01","dir":{"alis_dir":"up","satis_dir":"up"},"dusuk":1.9628,"yuksek":1.9628,"kapanis":1.4628},"EURKG":{"code":"EURKG","alis":51360,"satis":51500,"tarih":"10-02-2022 11:27:47","dir":{"alis_dir":"","satis_dir":""},"dusuk":51490,"yuksek":51630,"kapanis":51370},"JPYTRY":{"code":"JPYTRY","alis":0.1161,"satis":0.1169,"tarih":"10-02-2022 11:27:49","dir":{"alis_dir":"","satis_dir":""},"dusuk":0.1167,"yuksek":0.1174,"kapanis":0.116},"AEDUSD":{"code":"AEDUSD","alis":"0.2650","satis":"0.2750","tarih":"10-02-2022 11:15:01","dir":{"alis_dir":"up","satis_dir":"up"},"dusuk":0.275,"yuksek":0.275,"kapanis":0.265},"AYAR14":{"code":"AYAR14","alis":"437.110","satis":"525.310","tarih":"10-02-2022 11:27:49","dir":{"alis_dir":"","satis_dir":""},"dusuk":"525.240","yuksek":527.94,"kapanis":436.38},"GBPTRY":{"code":"GBPTRY","alis":18.265,"satis":18.353,"tarih":"10-02-2022 11:27:49","dir":{"alis_dir":"","satis_dir":""},"dusuk":18.306,"yuksek":18.394,"kapanis":18.221},"KWDUSD":{"code":"KWDUSD","alis":"3.2290","satis":"3.2790","tarih":"10-02-2022 11:15:01","dir":{"alis_dir":"up","satis_dir":"up"},"dusuk":3.279,"yuksek":3.279,"kapanis":3.229},"AYAR22":{"code":"AYAR22","alis":"724.550","satis":"744.950","tarih":"10-02-2022 11:27:49","dir":{"alis_dir":"","satis_dir":""},"dusuk":"744.850","yuksek":748.8,"kapanis":723.36},"DKKTRY":{"code":"DKKTRY","alis":2.047,"satis":2.091,"tarih":"10-02-2022 11:27:49","dir":{"alis_dir":"","satis_dir":""},"dusuk":2.086,"yuksek":2.099,"kapanis":2.044},"USDILS":{"code":"USDILS","alis":"3.4020","satis":"3.4720","tarih":"10-02-2022 11:15:01","dir":{"alis_dir":"up","satis_dir":"up"},"dusuk":3.472,"yuksek":3.472,"kapanis":3.402},"SEKTRY":{"code":"SEKTRY","alis":1.466,"satis":1.486,"tarih":"10-02-2022 11:27:49","dir":{"alis_dir":"","satis_dir":""},"dusuk":1.48,"yuksek":1.488,"kapanis":1.463},"USDMAD":{"code":"USDMAD","alis":"9.1030","satis":"9.6750","tarih":"10-02-2022 11:15:01","dir":{"alis_dir":"up","satis_dir":"up"},"dusuk":9.675,"yuksek":9.675,"kapanis":9.103},"KULCEALTIN":{"code":"KULCEALTIN","alis":794.42,"satis":802.87,"tarih":"10-02-2022 11:27:49","dir":{"alis_dir":"","satis_dir":""},"dusuk":802.77,"yuksek":806.94,"kapanis":793.11},"NOKTRY":{"code":"NOKTRY","alis":1.519,"satis":1.529,"tarih":"10-02-2022 11:27:49","dir":{"alis_dir":"","satis_dir":""},"dusuk":1.523,"yuksek":1.531,"kapanis":1.517},"USDQAR":{"code":"USDQAR","alis":3.891,"satis":3.991,"tarih":"10-02-2022 11:15:01","dir":{"alis_dir":"up","satis_dir":"up"},"dusuk":3.991,"yuksek":3.991,"kapanis":3.891},"XAUXAG":{"code":"XAUXAG","alis":78.43,"satis":78.49,"tarih":"10-02-2022 11:27:49","dir":{"alis_dir":"","satis_dir":""},"dusuk":78.45,"yuksek":79.11,"kapanis":78.66},"CEYREK_YENI":{"code":"CEYREK_YENI","alis":1297,"satis":1314,"tarih":"10-02-2022 11:27:49","dir":{"alis_dir":"","satis_dir":""},"dusuk":1314,"yuksek":1320,"kapanis":1295},"CHFTRY":{"code":"CHFTRY","alis":14.555,"satis":14.635,"tarih":"10-02-2022 11:27:49","dir":{"alis_dir":"","satis_dir":""},"dusuk":14.614,"yuksek":14.691,"kapanis":14.535},"JODUSD":{"code":"JODUSD","alis":1.306,"satis":1.406,"tarih":"10-02-2022 11:15:01","dir":{"alis_dir":"up","satis_dir":"up"},"dusuk":1.406,"yuksek":1.406,"kapanis":1.306},"CEYREK_ESKI":{"code":"CEYREK_ESKI","alis":1292,"satis":1306,"tarih":"10-02-2022 11:27:49","dir":{"alis_dir":"","satis_dir":""},"dusuk":1306,"yuksek":1312,"kapanis":1290},"AUDTRY":{"code":"AUDTRY","alis":9.558,"satis":9.705,"tarih":"10-02-2022 11:27:49","dir":{"alis_dir":"","satis_dir":""},"dusuk":9.674,"yuksek":9.721,"kapanis":9.531},"JODTRY":{"code":"JODTRY","alis":18.3283,"satis":19.0783,"tarih":"10-02-2022 11:27:49","dir":{"alis_dir":"down","satis_dir":"down"},"dusuk":19.0388,"yuksek":19.1148,"kapanis":18.33},"CADTRY":{"code":"CADTRY","alis":10.58,"satis":10.669,"tarih":"10-02-2022 11:27:49","dir":{"alis_dir":"","satis_dir":""},"dusuk":10.654,"yuksek":10.71,"kapanis":10.567},"YARIM_YENI":{"code":"YARIM_YENI","alis":2603,"satis":2628,"tarih":"10-02-2022 11:27:49","dir":{"alis_dir":"","satis_dir":""},"dusuk":2627,"yuksek":2641,"kapanis":2599},"OMRTRY":{"code":"OMRTRY","alis":34.3822,"satis":34.8822,"tarih":"10-02-2022 11:27:49","dir":{"alis_dir":"down","satis_dir":"down"},"dusuk":34.8094,"yuksek":34.9495,"kapanis":34.3853},"SARTRY":{"code":"SARTRY","alis":3.539,"satis":3.604,"tarih":"10-02-2022 11:27:49","dir":{"alis_dir":"","satis_dir":""},"dusuk":3.599,"yuksek":3.618,"kapanis":3.534},"USDCHF":{"code":"USDCHF","alis":"0.9260","satis":"0.9300","tarih":"10-02-2022 11:23:59","dir":{"alis_dir":"up","satis_dir":""},"dusuk":0.929,"yuksek":0.931,"kapanis":0.926},"YARIM_ESKI":{"code":"YARIM_ESKI","alis":2563,"satis":2588,"tarih":"10-02-2022 11:27:49","dir":{"alis_dir":"","satis_dir":""},"dusuk":2587,"yuksek":2601,"kapanis":2559},"AUDUSD":{"code":"AUDUSD","alis":"0.7060","satis":"0.7160","tarih":"10-02-2022 11:27:39","dir":{"alis_dir":"","satis_dir":""},"dusuk":0.713,"yuksek":0.716,"kapanis":0.705},"TEK_YENI":{"code":"TEK_YENI","alis":5190,"satis":5235,"tarih":"10-02-2022 11:27:49","dir":{"alis_dir":"","satis_dir":""},"dusuk":5234,"yuksek":5262,"kapanis":5181},"RUBTRY":{"code":"RUBTRY","alis":"0.1760","satis":"0.1830","tarih":"10-02-2022 11:27:49","dir":{"alis_dir":"","satis_dir":""},"dusuk":0.182,"yuksek":0.184,"kapanis":0.176},"USDCAD":{"code":"USDCAD","alis":"1.2700","satis":"1.2790","tarih":"10-02-2022 11:27:11","dir":{"alis_dir":"","satis_dir":""},"dusuk":1.279,"yuksek":1.281,"kapanis":1.27},"TEK_ESKI":{"code":"TEK_ESKI","alis":5142,"satis":5183,"tarih":"10-02-2022 11:27:49","dir":{"alis_dir":"","satis_dir":""},"dusuk":5182,"yuksek":5209,"kapanis":5133},"BGNTRY":{"code":"BGNTRY","alis":"7.6810","satis":"7.9810","tarih":"10-02-2022 11:27:49","dir":{"alis_dir":"","satis_dir":""},"dusuk":7.417,"yuksek":7.986,"kapanis":7.178},"USDDKK":{"code":"USDDKK","alis":"6.4810","satis":"6.6130","tarih":"10-02-2022 11:27:48","dir":{"alis_dir":"","satis_dir":"up"},"dusuk":6.61,"yuksek":6.622,"kapanis":6.483},"ATA_YENI":{"code":"ATA_YENI","alis":5329,"satis":5371,"tarih":"10-02-2022 11:27:49","dir":{"alis_dir":"","satis_dir":""},"dusuk":5371,"yuksek":5398,"kapanis":5321},"AEDTRY":{"code":"AEDTRY","alis":3.5974,"satis":3.6974,"tarih":"10-02-2022 11:27:49","dir":{"alis_dir":"","satis_dir":""},"dusuk":3.6898,"yuksek":3.7045,"kapanis":3.5977},"USDSAR":{"code":"USDSAR","alis":"3.7600","satis":"3.8250","tarih":"10-02-2022 11:15:01","dir":{"alis_dir":"up","satis_dir":"up"},"dusuk":3.825,"yuksek":3.825,"kapanis":3.76},"ATA_ESKI":{"code":"ATA_ESKI","alis":5325,"satis":5367,"tarih":"10-02-2022 11:27:49","dir":{"alis_dir":"","satis_dir":""},"dusuk":5367,"yuksek":5394,"kapanis":5317},"QARTRY":{"code":"QARTRY","alis":3.5849,"satis":3.6549,"tarih":"10-02-2022 11:27:49","dir":{"alis_dir":"","satis_dir":""},"dusuk":3.6472,"yuksek":3.662,"kapanis":3.5852},"USDSEK":{"code":"USDSEK","alis":"9.1550","satis":"9.2000","tarih":"10-02-2022 11:27:47","dir":{"alis_dir":"","satis_dir":""},"dusuk":"9.1850","yuksek":9.248,"kapanis":9.172},"ATA5_YENI":{"code":"ATA5_YENI","alis":26547,"satis":26746,"tarih":"10-02-2022 11:27:49","dir":{"alis_dir":"","satis_dir":""},"dusuk":26742,"yuksek":26881,"kapanis":26504},"CNYTRY":{"code":"CNYTRY","alis":"2.0420","satis":"2.0570","tarih":"10-02-2022 11:27:49","dir":{"alis_dir":"","satis_dir":""},"dusuk":2.053,"yuksek":2.061,"kapanis":2.042},"USDJPY":{"code":"USDJPY","alis":"115.89300","satis":"116.60300","tarih":"10-02-2022 11:27:48","dir":{"alis_dir":"up","satis_dir":"up"},"dusuk":116.491,"yuksek":116.709,"kapanis":115.824},"ATA5_ESKI":{"code":"ATA5_ESKI","alis":26507,"satis":26706,"tarih":"10-02-2022 11:27:49","dir":{"alis_dir":"","satis_dir":""},"dusuk":26702,"yuksek":26841,"kapanis":26464},"USDNOK":{"code":"USDNOK","alis":"8.8580","satis":"8.9180","tarih":"10-02-2022 11:27:49","dir":{"alis_dir":"","satis_dir":""},"dusuk":8.907,"yuksek":8.947,"kapanis":8.868},"GREMESE_YENI":{"code":"GREMESE_YENI","alis":12934,"satis":13098,"tarih":"10-02-2022 11:27:49","dir":{"alis_dir":"","satis_dir":""},"dusuk":13096,"yuksek":13164,"kapanis":12913},"GBPUSD":{"code":"GBPUSD","alis":"1.3490","satis":"1.3540","tarih":"10-02-2022 11:27:11","dir":{"alis_dir":"","satis_dir":""},"dusuk":1.352,"yuksek":"1.3550","kapanis":1.348},"GREMESE_ESKI":{"code":"GREMESE_ESKI","alis":12854,"satis":13018,"tarih":"10-02-2022 11:27:49","dir":{"alis_dir":"","satis_dir":""},"dusuk":13016,"yuksek":13083,"kapanis":12833},"GUMUSTRY":{"code":"GUMUSTRY","alis":10.138,"satis":10.441,"tarih":"10-02-2022 11:27:49","dir":{"alis_dir":"","satis_dir":""},"dusuk":10.392,"yuksek":10.458,"kapanis":10.099},"KWDTRY":{"code":"KWDTRY","alis":43.2153,"satis":45.2153,"tarih":"10-02-2022 11:27:49","dir":{"alis_dir":"down","satis_dir":"down"},"dusuk":45.1226,"yuksek":45.3009,"kapanis":43.2191},"ILSTRY":{"code":"ILSTRY","alis":4.1451,"satis":4.1551,"tarih":"10-02-2022 11:27:49","dir":{"alis_dir":"","satis_dir":""},"dusuk":4.1464,"yuksek":4.1631,"kapanis":4.1454},"XAGUSD":{"code":"XAGUSD","alis":23.35,"satis":23.36,"tarih":"10-02-2022 11:27:49","dir":{"alis_dir":"","satis_dir":""},"dusuk":23.2,"yuksek":23.41,"kapanis":23.29},"GUMUSUSD":{"code":"GUMUSUSD","alis":749,"satis":770,"tarih":"10-02-2022 11:27:48","dir":{"alis_dir":"","satis_dir":""},"dusuk":765,"yuksek":772,"kapanis":747},"MADTRY":{"code":"MADTRY","alis":1.5091,"satis":1.5141,"tarih":"10-02-2022 11:27:49","dir":{"alis_dir":"","satis_dir":""},"dusuk":1.5109,"yuksek":1.5169,"kapanis":1.5091},"XPTUSD":{"code":"XPTUSD","alis":1033,"satis":1036,"tarih":"10-02-2022 11:27:48","dir":{"alis_dir":"","satis_dir":""},"dusuk":1034,"yuksek":1041,"kapanis":1036},"XPDUSD":{"code":"XPDUSD","alis":2287,"satis":2296,"tarih":"10-02-2022 11:27:44","dir":{"alis_dir":"","satis_dir":""},"dusuk":2282,"yuksek":2298,"kapanis":2280},"PLATIN":{"code":"PLATIN","alis":28220,"satis":33300,"tarih":"10-02-2022 11:27:48","dir":{"alis_dir":"up","satis_dir":""},"dusuk":33250,"yuksek":33460,"kapanis":28320},"PALADYUM":{"code":"PALADYUM","alis":63530,"satis":73830,"tarih":"10-02-2022 11:27:44","dir":{"alis_dir":"","satis_dir":""},"dusuk":73350,"yuksek":73870,"kapanis":63300}}}</body>

</html>