File manager - Edit - /home/cipherteam/htdocs/cipherteam.in/API/Finance/MCMCX.php
Back
<?php $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://in.investing.com/commodities/real-time-futures', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_HTTPHEADER => array( 'authority: in.investing.com', 'accept: application/json, text/javascript, */*; q=0.01', 'accept-language: en-US,en;q=0.9,gu;q=0.8,zh-TW;q=0.7,zh;q=0.6', 'referer: https://in.investing.com/commodities/real-time-futures', 'res-scheme: 1', 'sec-ch-ua: "Google Chrome";v="107", "Chromium";v="107", "Not=A?Brand";v="24"', 'sec-ch-ua-mobile: ?0', 'sec-ch-ua-platform: "Windows"', 'sec-fetch-dest: empty', 'sec-fetch-mode: cors', 'sec-fetch-site: same-origin', 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36', 'x-requested-with: XMLHttpRequest' ), )); $response = curl_exec($curl); curl_close($curl); $data = json_decode($response,true); $rows = $data["body"]["content"]["nested"]["table"]["_list"][0]["nested"]["body"]["vars"]["data"]["rows"]; $gainers["MCX"] = array(); foreach($rows as $row) { $name = $row[2][0]; if (strpos($name, "MCX") !== false) { $name = str_replace('MCX ','',$name); } else continue; $date = $row[3]; $price = $row[4][0]; $change = $row[7][0]; $changeper = $row[8][0]; $gainer = array( 'NAME'=>$name, 'PRICE'=>$price, 'DATE'=>$date, 'CHANGE'=>$change, 'CHANGEPER'=>$changeper ); array_push($gainers["MCX"],$gainer); } $gainers["success"] = 1; echo json_encode($gainers); ?>
| ver. 1.4 |
Github
|
.
| PHP 8.2.9 | Generation time: 0.01 |
proxy
|
phpinfo
|
Settings