public static function vFetch($bParse = true) { Curl::$oDefault->vSetCookieJarFile('store/cookie'); $aDetailUrlItems = self::aGetCurrentDetailUrlItems(); foreach ($aDetailUrlItems as $oItem) { $sTime = date('Y-m-d H:i:s'); $sListID = $oItem->sListID; $sDetailUrl = $oItem->sUrl; $bFetch = true; $oLatestFetchedHtml = Ad::oGetLatestHtmlForUrl($sDetailUrl); $oEarliestFetchedHtml = Ad::oGetEarliestHtmlForUrl($sDetailUrl); if ($oLatestFetchedHtml && $oEarliestFetchedHtml) { $nLatestAge = Utilitu::nDateDiff($oLatestFetchedHtml->fetched, 'now', 'hours'); $nEarliestAge = Utilitu::nDateDiff($oEarliestFetchedHtml->fetched, 'now', 'hours'); $bHalfHour = 0.5 < $nLatestAge; $bManyHours = 16 < $nLatestAge; $bDoubleTimePassed = $nEarliestAge < 2 * $nLatestAge; if (!($bManyHours || $bHalfHour && $bDoubleTimePassed)) { $bFetch = false; } file_put_contents('fetch.log', $sDetailUrl . ' | ' . $nEarliestAge . ' - ' . $nLatestAge . ' | ' . ($bFetch ? 'true' : 'false') . "\n", FILE_APPEND); } if ($bFetch) { $sDetailHtml = Curl::sGetTwice($sDetailUrl, 1.5); $iHtmlID = Ad::iSaveHtml($sListID, $sDetailUrl, $sDetailHtml, $sTime); if ($bParse) { $oAd = self::oParseHtml($iHtmlID); } } } }