File manager - Edit - /home/cipherteam/htdocs/cipherteam.in/API/STOCK_NEWS/V2NEW/MostTraded.php
Back
<?php include_once("Market.php"); if(!isMarketOpen()) { include_once("simple_html_dom.php"); include_once("Connection.php"); try { $html = file_get_html("https://money.rediff.com/companies/most-traded/nse"); $tbody = $html->find('tbody',0); if(!$tbody) { throw new Exception('Exception message'); } $gainers["TRADED"] = 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_traded`"; $con->query($sql); $first = false; } $cname = trim($tr->find('td', 0)->plaintext); $price = trim($tr->find('td', 1)->plaintext); $chng = trim($tr->find('td', 2)->plaintext); $volume = trim($tr->find('td', 3)->plaintext); $gainer = array( 'NAME'=>$cname, 'PRICE'=>$price, 'CHANGE'=>$chng, 'VOLUME'=>$volume ); $sql = "INSERT INTO `most_traded` (`name`, `ltp`, `chng`, `volume`) VALUES ('$cname', '$price', '$chng', '$volume');"; $con->query($sql); array_push($gainers["TRADED"],$gainer); } $gainers["success"] = 1; echo json_encode($gainers); } catch(Exception $e) { $sql = "SELECT `name` AS 'NAME',`ltp` AS 'PRICE',`chng` AS 'CHANGE',`volume` AS 'VOLUME' FROM `most_traded`;"; $rows = $con->query($sql); $gainers["TRADED"] = array(); if($rows->num_rows > 0) { while($row = $rows->fetch_assoc()) { $div = array(); $div = $row; array_push($gainers["TRADED"],$div); } $gainers["success"] = 1; echo json_encode($gainers); } } } else { include_once("Connection.php"); $sql = "SELECT `name` AS 'NAME',`ltp` AS 'PRICE',`chng` AS 'CHANGE',`volume` AS 'VOLUME' FROM `most_traded`;"; $rows = $con->query($sql); $gainers["TRADED"] = array(); if($rows->num_rows > 0) { while($row = $rows->fetch_assoc()) { $div = array(); $div = $row; array_push($gainers["TRADED"],$div); } $gainers["success"] = 1; echo json_encode($gainers); } } ?>
| ver. 1.4 |
Github
|
.
| PHP 8.2.9 | Generation time: 0.18 |
proxy
|
phpinfo
|
Settings