File manager - Edit - /home/cipherteam/htdocs/cipherteam.in/API/STOCK_NEWS/V2NEW/BulkDeal.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://www.moneycontrol.com/stocks/marketstats/bulk-deals/nse/"); $table = $html->find('table',1); $tbody = $html->find('tbody',0); if(!$tbody) { throw new Exception('Exception message'); } $gainers["BULK"] = 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 `bulk_deals`"; $con->query($sql); $first = false; } $date = trim($tr->find('td', 0)->plaintext); $cname = trim($tr->find('td', 1)->plaintext); $client = trim($tr->find('td', 2)->plaintext); $trade = trim($tr->find('td', 3)->plaintext); $qty = trim($tr->find('td', 4)->plaintext); $tprice = trim($tr->find('td', 5)->plaintext); $cprice = trim($tr->find('td', 6)->plaintext); $gainer = array( 'DATE'=>$date, 'CNAME'=>$cname, 'CLIENT'=>$client, 'TRADE'=>$trade, 'QTY'=>$qty, 'TPRICE'=>$tprice, 'CPRICE'=>$cprice ); $sql = "INSERT INTO `bulk_deals` (`date`, `company_name`, `client_name`, `trade`, `qty`, `tprice`, `cprice`) VALUES ('$date', '$cname', '$client', '$trade', '$qty', '$tprice', '$cprice');"; $con->query($sql); array_push($gainers["BULK"],$gainer); } $gainers["success"] = 1; echo json_encode($gainers); } catch(Exception $e) { $sql = "SELECT `date` AS 'DATE', `company_name` AS 'CNAME',`client_name` AS 'CLIENT',`trade` AS 'TRADE',`qty` AS 'QTY',`tprice` AS 'TPRICE',`cprice` AS 'CPRICE' FROM `bulk_deals`;"; $rows = $con->query($sql); $gainers["BULK"] = array(); if($rows->num_rows > 0) { while($row = $rows->fetch_assoc()) { $div = array(); $div = $row; array_push($gainers["BULK"],$div); } $gainers["success"] = 1; echo json_encode($gainers); } } } else { include_once("Connection.php"); $sql = "SELECT `date` AS 'DATE', `company_name` AS 'CNAME',`client_name` AS 'CLIENT',`trade` AS 'TRADE',`qty` AS 'QTY',`tprice` AS 'TPRICE',`cprice` AS 'CPRICE' FROM `bulk_deals`;"; $rows = $con->query($sql); $gainers["BULK"] = array(); if($rows->num_rows > 0) { while($row = $rows->fetch_assoc()) { $div = array(); $div = $row; array_push($gainers["BULK"],$div); } $gainers["success"] = 1; echo json_encode($gainers); } } ?>
| ver. 1.4 |
Github
|
.
| PHP 8.2.9 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings