I would like to copy the rates from the page at : www.planipret.com
and then display them onto my own page. The info is actually in 2 divs.
Im using this code someone made for me but the display needs to be formatted or output in a loop. This code is too advanced for me to alter.
thanks anyone who can offer help.
<?php
$sCacheFile = 'rates.cache.html';
$sQuery = "//div[@class='sidebarlight' or @class='sidebardark']";
$sWebsiteUrl = 'http://www.planipret.com/';
$sAlternate = '<a href="http://www.planipret.com/" target="_blank">Check on the Planiprep Website</a>';
$b****sBroke = false;
$oDoc = new DOMDocument('1.0', 'iso-8859-1');
$sWebsiteContents = @file_get_contents($sWebsiteUrl);
@$oDoc->loadHTML($sWebsiteContents);
$oPath = new DOMXPath($oDoc);
$oPath->registerNamespace('html', 'http://www.w3.org/1999/xhtml');
$oList = $oPath->query($sQuery);
// store/load from cache
if ($oList->length === 0) {
$sHtml = @file_get_contents($sCacheFile);
} else {
$sHtml = '';
foreach($oList as $oNode) {
$oNodeDoc = new DOMDocument();
$oNodeDoc->appendChild($oNodeDoc->importNode($oNode,true));
$sHtml .= $oNodeDoc->saveHTML();
}
file_put_contents($sCacheFile, $sHtml);
}
$b****sBroke = (strlen($sHtml)==0);
if ($b****sBroke) {
print($sAlternate);
} else {
print($sHtml);
}
?>