File manager - Edit - /home/cipherteam/htdocs/cipherteam.in/API/Finance/MostActiveByVol.php
Back
<?php include_once("Market.php"); if(isMarketOpen()) { include_once("simple_html_dom.php"); include_once("ConnectToMarketData.php"); try { $html = file_get_html("https://ticker.finology.in/market"); $div = $html->find('div[id=mainContent_MostActiveVolume]',0); $tbody = $html->find('tbody',0); if(!$tbody) { throw new Exception('Exception message'); } $gainers["MOSTACTIVE"] = array(); $tmp = $tbody->find('tr',0); if(!$tmp) { throw new Exception('Exception message'); } $first = true; foreach($tbody->find('tr') as $tr) { if($first) { $sql = "DELETE FROM `most_active_vol`"; $con->query($sql); $first = false; } $cname = trim($tr->find('td', 0)->plaintext); $val = $tr->find('td', 1)->plaintext; $gainer = array( 'NAME'=>$cname, 'VAL'=>$val ); $sql = "INSERT INTO `most_active_vol` (`cname`, `val`) VALUES ('$cname', '$val');"; $con->query($sql); array_push($gainers["MOSTACTIVE"],$gainer); } $gainers["success"] = 1; echo json_encode($gainers); } catch(Exception $e) { $sql = "SELECT `cname` AS 'NAME',`val` AS 'VAL' FROM `most_active_vol`"; $rows = $con->query($sql); $gainers["MOSTACTIVE"] = array(); if($rows->num_rows > 0) { while($row = $rows->fetch_assoc()) { $div = array(); $div = $row; array_push($gainers["MOSTACTIVE"],$div); } $gainers["success"] = 1; echo json_encode($gainers); } } } else { include_once("ConnectToMarketData.php"); $sql = "SELECT `cname` AS 'NAME',`val` AS 'VAL' FROM `most_active_vol`"; $rows = $con->query($sql); $gainers["MOSTACTIVE"] = array(); if($rows->num_rows > 0) { while($row = $rows->fetch_assoc()) { $div = array(); $div = $row; array_push($gainers["MOSTACTIVE"],$div); } $gainers["success"] = 1; echo json_encode($gainers); } } ?>
| ver. 1.4 |
Github
|
.
| PHP 8.2.9 | Generation time: 0.05 |
proxy
|
phpinfo
|
Settings