本文整理汇总了PHP中Ad::oGetEarliestHtmlForUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP Ad::oGetEarliestHtmlForUrl方法的具体用法?PHP Ad::oGetEarliestHtmlForUrl怎么用?PHP Ad::oGetEarliestHtmlForUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ad
的用法示例。
在下文中一共展示了Ad::oGetEarliestHtmlForUrl方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: vFetch
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);
}
}
}
}