Created
January 16, 2025 16:19
-
-
Save olegopro/ba3313d11ea62da1a6b46113a80a287b to your computer and use it in GitHub Desktop.
Извлечение уникальных доменов из файла .har с помощью PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Путь к вашему файлу .har | |
$filePath = '/Users/evilgazz/Desktop/chat.mistral.ai.har'; | |
// Загрузите содержимое файла .har | |
$harContent = file_get_contents($filePath); | |
// Декодируйте JSON | |
$harData = json_decode($harContent, true); | |
// Регулярное выражение для извлечения доменов | |
$domainPattern = '/https?:\/\/([^\/"]+)/'; | |
// Извлечение всех URL | |
$urls = array_column($harData['log']['entries'], 'request', 'url'); | |
// Извлечение доменов | |
$domains = []; | |
foreach ($harData['log']['entries'] as $entry) { | |
$url = $entry['request']['url']; | |
if (preg_match($domainPattern, $url, $matches)) { | |
$domains[] = $matches[1]; | |
} | |
} | |
// Удаление дубликатов | |
$uniqueDomains = array_unique($domains); | |
// Вывод доменов | |
foreach ($uniqueDomains as $domain) { | |
echo $domain . PHP_EOL; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment