https://www.kasikornbank.com/TH/Rate/Pages/Foreign-Exchange.aspx
https://stackoverflow.com/questions/24134886/get-html-code-from-aspx-page-with-php
- <?php
- include_once("simple_html_dom.php");
- $url = 'https://www.kasikornbank.com/TH/Rate/Pages/Foreign-Exchange.aspx';
- $contents = htmlentities(file_get_contents($url));
- echo $contents;
- ?>
สามารถส่งวันที่ เข้าไปได้ ก็จะได้ค่าเช่นกัน
- <?php
- include_once("simple_html_dom.php");
- $url = 'https://www.kasikornbank.com/TH/Rate/Pages/Foreign-Exchange.aspx?d=19&m=05&y=2017&r=0';
- $contents = htmlentities(file_get_contents($url));
- echo $contents;
- ?>
เอาค่ามาใช้งานโดย ใช้ explode <div> เอา
https://stackoverflow.com/questions/20446598/get-div-content-from-external-website
- <?php
- include_once("simple_html_dom.php");
- $url = 'https://www.kasikornbank.com/TH/Rate/Pages/Foreign-Exchange.aspx';
- //$contents = htmlentities(file_get_contents($url));
- //$contents = file_get_contents($url);
- //echo $contents;
- //exit;
- // FIND THE DESIRED DIV
- $htm = file_get_contents($url);
- echo htmlentities($htm);
- $strDate = '<div id="divRate"';
- $arrDate = explode($strDate, $htm);
- $arrDate = explode('</div', $arrDate[1]);
- // RECONSTRUCT THE DIV WITH HTML TAGS
- $new = $strDate . $arrDate[0] .'</div>';
- echo htmlentities($new);
- ?>
ตัวอย่าง Rate ข้อเสนอแนะคุณพเยาว์
https://intranet.scivalve.com/sci/AF/rate_bank.php
- <?php
- error_reporting(E_ERROR);
- define('IN_PHPBB', true);
- $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : '../../';
- $phpEx = substr(strrchr(__FILE__, '.'), 1);
- include($phpbb_root_path . 'common.' . $phpEx);
- include($phpbb_root_path ."sci/include/config.php");
- //include($phpbb_root_path ."sci/include/db.php");
- include($phpbb_root_path ."sci/include/functions.php");
- //include($phpbb_root_path ."sci/include/db2.php");
- include_once("simple_html_dom.php");
- //$url = 'https://www.kasikornbank.com/TH/Rate/Pages/Foreign-Exchange.aspx?d=19&m=05&y=2017&r=0';
- $url = 'https://www.kasikornbank.com/TH/Rate/Pages/Foreign-Exchange.aspx';
- //$contents = htmlentities(file_get_contents($url));
- //$contents = file_get_contents($url);
- //echo $contents;
- //exit;
- // FIND THE DESIRED DIV
- $htm = file_get_contents($url);
- echo htmlentities($htm);
- /*
- $strDate = '<div id="divRate"';
- $arrDate = explode($strDate, $htm);
- $arrDate = explode('</div', $arrDate[1]);
- // RECONSTRUCT THE DIV WITH HTML TAGS
- $new = $strDate . $arrDate[0] .'</div>';
- echo htmlentities($new);
- */
- //########### USD ############//
- $strDiv = '<div id="divLastRate"';
- $arrDiv = explode($strDiv, $htm);
- $arrDiv = explode('</div>', $arrDiv[1]);
- // RECONSTRUCT THE DIV WITH HTML TAGS
- $newDiv = $strDiv . $arrDiv[0] .'</div>';
- //echo htmlentities($newDiv);
- // Explode Data For Show Buying.
- $strBuyUSD = 'data-BuyTelex="';
- $arrBuyUSD = explode($strBuyUSD, $newDiv);
- $arrBuyUSD = explode('"', $arrBuyUSD[1]);
- $newBuyUSD = $arrBuyUSD[0];
- //echo $newBuyUSD;
- // Explode Data For Show Selling.
- $strSellUSD = 'data-SellChq="';
- $arrSellUSD = explode($strSellUSD, $newDiv);
- $arrSellUSD = explode('"', $arrSellUSD[1]);
- $newSellUSD = $arrSellUSD[0];
- //echo $newSellUSD;
- //########### USD ############//
- //########### CNY ############//
- $strDiv = '<div id="divLastRate"';
- $arrDiv = explode($strDiv, $htm);
- $arrDiv = explode('</div>', $arrDiv[1]);
- // RECONSTRUCT THE DIV WITH HTML TAGS
- $newDiv = $strDiv . $arrDiv[10] .'</div>';
- //echo htmlentities($newDiv);
- // Explode Data For Show Buying.
- $strBuyCNY = 'data-BuyTelex="';
- $arrBuyCNY = explode($strBuyCNY, $newDiv);
- $arrBuyCNY = explode('"', $arrBuyCNY[1]);
- $newBuyCNY = $arrBuyCNY[0];
- //echo $newBuyCNY;
- // Explode Data For Show Selling.
- $strSellCNY = 'data-SellChq="';
- $arrSellCNY = explode($strSellCNY, $newDiv);
- $arrSellCNY = explode('"', $arrSellCNY[1]);
- $newSellCNY = $arrSellCNY[0];
- //echo $newSellCNY;
- //########### CNY ############//
- //########### EUR ############//
- $strDiv = '<div id="divLastRate"';
- $arrDiv = explode($strDiv, $htm);
- $arrDiv = explode('</div>', $arrDiv[1]);
- // RECONSTRUCT THE DIV WITH HTML TAGS
- $newDiv = $strDiv . $arrDiv[12] .'</div>';
- //echo htmlentities($newDiv);
- // Explode Data For Show Buying.
- $strBuyEUR = 'data-BuyTelex="';
- $arrBuyEUR = explode($strBuyEUR, $newDiv);
- $arrBuyEUR = explode('"', $arrBuyEUR[1]);
- $newBuyEUR = $arrBuyEUR[0];
- //echo $newBuyEUR;
- // Explode Data For Show Selling.
- $strSellEUR = 'data-SellChq="';
- $arrSellEUR = explode($strSellEUR, $newDiv);
- $arrSellEUR = explode('"', $arrSellEUR[1]);
- $newSellEUR = $arrSellEUR[0];
- //echo $newSellEUR;
- //########### EUR ############//
- //########### GBP ############//
- $strDiv = '<div id="divLastRate"';
- $arrDiv = explode($strDiv, $htm);
- $arrDiv = explode('</div>', $arrDiv[1]);
- // RECONSTRUCT THE DIV WITH HTML TAGS
- $newDiv = $strDiv . $arrDiv[13] .'</div>';
- //echo htmlentities($newDiv);
- // Explode Data For Show Buying.
- $strBuyGBP = 'data-BuyTelex="';
- $arrBuyGBP = explode($strBuyGBP, $newDiv);
- $arrBuyGBP = explode('"', $arrBuyGBP[1]);
- $newBuyGBP = $arrBuyGBP[0];
- //echo $newBuyGBP;
- // Explode Data For Show Selling.
- $strSellGBP = 'data-SellChq="';
- $arrSellGBP = explode($strSellGBP, $newDiv);
- $arrSellGBP = explode('"', $arrSellGBP[1]);
- $newSellGBP = $arrSellGBP[0];
- //echo $newSellGBP;
- //########### GBP ############//
- //########### HKD ############//
- $strDiv = '<div id="divLastRate"';
- $arrDiv = explode($strDiv, $htm);
- $arrDiv = explode('</div>', $arrDiv[1]);
- // RECONSTRUCT THE DIV WITH HTML TAGS
- $newDiv = $strDiv . $arrDiv[14] .'</div>';
- //echo htmlentities($newDiv);
- // Explode Data For Show Buying.
- $strBuyHKD = 'data-BuyTelex="';
- $arrBuyHKD = explode($strBuyHKD, $newDiv);
- $arrBuyHKD = explode('"', $arrBuyHKD[1]);
- $newBuyHKD = $arrBuyHKD[0];
- //echo $newBuyHKD;
- // Explode Data For Show Selling.
- $strSellHKD = 'data-SellChq="';
- $arrSellHKD = explode($strSellHKD, $newDiv);
- $arrSellHKD = explode('"', $arrSellHKD[1]);
- $newSellHKD = $arrSellHKD[0];
- //echo $newSellHKD;
- //########### HKD ############//
- //########### JPY ############//
- $strDiv = '<div id="divLastRate"';
- $arrDiv = explode($strDiv, $htm);
- $arrDiv = explode('</div>', $arrDiv[1]);
- // RECONSTRUCT THE DIV WITH HTML TAGS
- $newDiv = $strDiv . $arrDiv[18] .'</div>';
- //echo htmlentities($newDiv);
- // Explode Data For Show Buying.
- $strBuyJPY = 'data-BuyTelex="';
- $arrBuyJPY = explode($strBuyHKD, $newDiv);
- $arrBuyJPY = explode('"', $arrBuyHKD[1]);
- $newBuyJPY = $arrBuyHKD[0];
- //echo $newBuyJPY;
- // Explode Data For Show Selling.
- $strSellJPY = 'data-SellChq="';
- $arrSellJPY = explode($strSellJPY, $newDiv);
- $arrSellJPY = explode('"', $arrSellJPY[1]);
- $newSellJPY = $arrSellJPY[0];
- //echo $newSellJPY;
- //########### JPY ############//
- //########### MYR ############//
- $strDiv = '<div id="divLastRate"';
- $arrDiv = explode($strDiv, $htm);
- $arrDiv = explode('</div>', $arrDiv[1]);
- // RECONSTRUCT THE DIV WITH HTML TAGS
- $newDiv = $strDiv . $arrDiv[24] .'</div>';
- //echo htmlentities($newDiv);
- // Explode Data For Show Buying.
- $strBuyMYR = 'data-BuyTelex="';
- $arrBuyMYR = explode($strBuyHKD, $newDiv);
- $arrBuyMYR = explode('"', $arrBuyMYR[1]);
- $newBuyMYR = $arrBuyMYR[0];
- //echo $newBuyMYR;
- // Explode Data For Show Selling.
- $strSellMYR = 'data-SellChq="';
- $arrSellMYR = explode($strSellMYR, $newDiv);
- $arrSellMYR = explode('"', $arrSellMYR[1]);
- $newSellMYR = $arrSellMYR[0];
- //echo $newSellMYR;
- //########### MYR ############//
- //########### SGD ############//
- $strDiv = '<div id="divLastRate"';
- $arrDiv = explode($strDiv, $htm);
- $arrDiv = explode('</div>', $arrDiv[1]);
- // RECONSTRUCT THE DIV WITH HTML TAGS
- $newDiv = $strDiv . $arrDiv[24] .'</div>';
- //echo htmlentities($newDiv);
- // Explode Data For Show Buying.
- $strBuySGD = 'data-BuyTelex="';
- $arrBuySGD = explode($strBuySGD, $newDiv);
- $arrBuySGD = explode('"', $arrBuySGD[1]);
- $newBuySGD = $arrBuySGD[0];
- //echo $newBuySGD;
- // Explode Data For Show Selling.
- $strSellSGD = 'data-SellChq="';
- $arrSellSGD = explode($strSellSGD, $newDiv);
- $arrSellSGD = explode('"', $arrSellSGD[1]);
- $newSellSGD = $arrSellSGD[0];
- //echo $newSellSGD;
- //########### SGD ############//
- ?>
No comments:
Post a Comment