File manager - Edit - /home/cipherteam/htdocs/cipherteam.in/API/STOCK_NEWS/V2NEW/BSEIndex.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://ticker.finology.in/market/index/bse"); $tbody = $html->find('tbody',0); if(!$tbody) { throw new Exception('Exception message'); } $gainers["BSE"] = 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 `bse_index`"; $con->query($sql); $first = false; } $name = $tr->find('td', 1)->plaintext; $curval = $tr->find('td', 2)->plaintext; $change = $tr->find('td', 3)->plaintext; $change = str_replace(' ', '', $change); $ch = '+'; if (strpos($change, '-') !== false) { $ch = '-'; $change = str_replace('-', '', $change); } $change = number_format($change, 2, '.', ''); $change = $ch.$change; $changeper = $tr->find('td', 4)->plaintext; $changeper = str_replace('%','',$changeper); $changeper = str_replace(' ', '', $changeper); $ch = '+'; if (strpos($changeper, '-') !== false) { $ch = '-'; $changeper = str_replace('-', '', $changeper); } $changeper = number_format($changeper, 2, '.', ''); $changeper = $ch.$changeper.'%'; $gainer = array( 'NAME'=>$name, 'CURVAL'=>$curval, 'CHANGE'=>$change, 'CHANGEPER'=>$changeper ); $sql = "INSERT INTO `bse_index` (`name`, `curval`, `chng`, `chngper`) VALUES ('$name', '$curval', '$change', '$changeper');"; $con->query($sql); array_push($gainers["BSE"],$gainer); } $gainers["success"] = 1; echo json_encode($gainers); } catch(Exception $e) { $sql = "SELECT `name` AS 'NAME', `curval` AS 'CURVAL',`chng` AS 'CHANGE',`chngper` AS 'CHANGEPER' FROM `bse_index`;"; $rows = $con->query($sql); $gainers["BSE"] = array(); if($rows->num_rows > 0) { while($row = $rows->fetch_assoc()) { $div = array(); $div = $row; array_push($gainers["BSE"],$div); } $gainers["success"] = 1; echo json_encode($gainers); } } } else { include_once("Connection.php"); $sql = "SELECT `name` AS 'NAME', `curval` AS 'CURVAL',`chng` AS 'CHANGE',`chngper` AS 'CHANGEPER' FROM `bse_index`;"; $rows = $con->query($sql); $gainers["BSE"] = array(); if($rows->num_rows > 0) { while($row = $rows->fetch_assoc()) { $div = array(); $div = $row; array_push($gainers["BSE"],$div); } $gainers["success"] = 1; echo json_encode($gainers); } } ?>
| ver. 1.4 |
Github
|
.
| PHP 8.2.9 | Generation time: 0.07 |
proxy
|
phpinfo
|
Settings