老模板优化
This commit is contained in:
@@ -15,6 +15,9 @@ class DomainSpiderCrawlLogHelper
|
||||
$arrItem['host'] = strtolower(trim((string)($arrItem['host'] ?? '')));
|
||||
$arrItem['path'] = trim((string)($arrItem['path'] ?? ''));
|
||||
$arrItem['page_type'] = DomainSpiderCrawlLogSchemaHelper::normalizePageType((string)($arrItem['page_type'] ?? 'other'));
|
||||
if ($arrItem['page_type'] === 'other') {
|
||||
$arrItem['page_type'] = DomainSpiderCrawlLogSchemaHelper::inferPageTypeFromPath((string)$arrItem['path'], 'other');
|
||||
}
|
||||
$arrItem['bot_name'] = DomainSpiderCrawlLogSchemaHelper::normalizeBotName((string)($arrItem['bot_name'] ?? 'other_bot'));
|
||||
$arrItem['status'] = (int)($arrItem['status'] ?? 0);
|
||||
$arrItem['count'] = max(0, (int)($arrItem['count'] ?? 0));
|
||||
@@ -26,6 +29,9 @@ class DomainSpiderCrawlLogHelper
|
||||
$arrItem['host'] = strtolower(trim((string)($arrItem['host'] ?? '')));
|
||||
$arrItem['url'] = trim((string)($arrItem['url'] ?? ''));
|
||||
$arrItem['page_type'] = DomainSpiderCrawlLogSchemaHelper::normalizePageType((string)($arrItem['page_type'] ?? 'other'));
|
||||
if ($arrItem['page_type'] === 'other') {
|
||||
$arrItem['page_type'] = DomainSpiderCrawlLogSchemaHelper::inferPageTypeFromPath((string)$arrItem['url'], 'other');
|
||||
}
|
||||
$arrItem['bot_name'] = DomainSpiderCrawlLogSchemaHelper::normalizeBotName((string)($arrItem['bot_name'] ?? 'other_bot'));
|
||||
$arrItem['status'] = (int)($arrItem['status'] ?? 0);
|
||||
$arrItem['cache_status'] = self::normalizeCacheStatus((string)($arrItem['cache_status'] ?? ''));
|
||||
|
||||
@@ -202,6 +202,60 @@ class DomainSpiderCrawlLogSchemaHelper
|
||||
return in_array($strPageType, self::buildSchema()['page_type_enum'], true) ? $strPageType : 'other';
|
||||
}
|
||||
|
||||
public static function inferPageTypeFromPath(string $strPath, string $strFallback = 'other'): string
|
||||
{
|
||||
$strPath = strtolower(trim($strPath));
|
||||
if ($strPath === '') {
|
||||
return self::normalizePageType($strFallback);
|
||||
}
|
||||
|
||||
$strPath = parse_url($strPath, PHP_URL_PATH) ?: $strPath;
|
||||
$strPath = '/' . ltrim($strPath, '/');
|
||||
$strNormalized = trim($strPath, '/');
|
||||
|
||||
if ($strNormalized === '' || $strNormalized === 'index.php') {
|
||||
return 'home';
|
||||
}
|
||||
|
||||
if ($strNormalized === 'robots.txt') {
|
||||
return 'robots';
|
||||
}
|
||||
|
||||
if (str_contains($strNormalized, 'sitemap')) {
|
||||
return 'sitemap';
|
||||
}
|
||||
|
||||
if (str_starts_with($strNormalized, 'search') || str_starts_with($strNormalized, 'get-index')) {
|
||||
return 'search';
|
||||
}
|
||||
|
||||
if (
|
||||
str_contains($strNormalized, 'videotype')
|
||||
|| str_contains($strNormalized, 'vodtype')
|
||||
|| str_contains($strNormalized, 'fenlei')
|
||||
) {
|
||||
return 'category';
|
||||
}
|
||||
|
||||
if (
|
||||
str_starts_with($strNormalized, 'voddetail/')
|
||||
|| str_starts_with($strNormalized, 'video-info/')
|
||||
|| str_starts_with($strNormalized, 'neirong-')
|
||||
) {
|
||||
return 'detail';
|
||||
}
|
||||
|
||||
if (
|
||||
str_starts_with($strNormalized, 'vodplay/')
|
||||
|| str_starts_with($strNormalized, 'video-play/')
|
||||
|| str_starts_with($strNormalized, 'bf-')
|
||||
) {
|
||||
return 'play';
|
||||
}
|
||||
|
||||
return self::normalizePageType($strFallback);
|
||||
}
|
||||
|
||||
public static function normalizeBotName(string $strBotName): string
|
||||
{
|
||||
$strValue = strtolower(trim($strBotName));
|
||||
|
||||
Reference in New Issue
Block a user