Created
March 13, 2024 09:39
-
-
Save webnitros/bf0ca7d6d42ba47e65dab9b26cbf646a to your computer and use it in GitHub Desktop.
This file contains 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 | |
$time = microtime(true); | |
$file = 'links.txt'; | |
if (file_exists($file)) { | |
$content = file_get_contents($file); | |
} else { | |
$content = file_get_contents('https://artelamp.ru/test.php'); | |
file_put_contents($file, $content); | |
} | |
$arrays = explode('<br>', $content); | |
#$arrays = explode(PHP_EOL, $content); | |
$domain = 'https://artelamp.prod1.massive.ru/'; | |
$urls = []; | |
$filename = 'results.csv'; | |
if (file_exists($filename)) { | |
unlink($filename); | |
} | |
// Открываем файл для записи | |
$file = fopen($filename, 'w'); | |
// Записываем заголовки | |
fputcsv($file, ['url', 'status']); | |
#$chums = array_chunk($arrays, 3); | |
$count = 0; | |
foreach ($arrays as $uri) { | |
$url = $domain . $uri; | |
$headers = get_headers($url, 0); | |
$code = substr($headers[0], 9, 3); | |
fputcsv($file, [$url, $code]); | |
$count++; | |
} | |
// Закрываем файл | |
fclose($file); | |
$time = ((microtime(true) - $time)); | |
echo 'Экспорт завершен успешно. Обработано ' . $count . ' записей'; | |
echo PHP_EOL; | |
echo ' - Время выполнения: ' . $time . ' секунд'; | |
echo '<pre>'; | |
print_r(22); | |
die; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment