Сообщение от Decode
|
еще появляется код 0? что это значит?
|
Цитата:
|
If you connect with the server, then you can get a return code from it, otherwise it will fail and you get a 0
|
©
https://stackoverflow.com/questions/...-code-return-0
Сообщение от Decode
|
как сделать, чтобы редиректы и 404 игнорировались?
|
Примерно так:
<?php
$lines = file('temp.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$multi = curl_multi_init();
$channels = array();
foreach ($lines as $line) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $line);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_multi_add_handle($multi, $ch);
$channels[$line] = $ch;
}
$active = null;
do {
$mrc = curl_multi_exec($multi, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
while ($active && $mrc == CURLM_OK) {
if (curl_multi_select($multi) == -1) {
continue;
}
do {
$mrc = curl_multi_exec($multi, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
}
foreach ($channels as $channel) {
$statusCode = (int) curl_getinfo($channel, CURLINFO_HTTP_CODE);
if (!in_array($statusCode, [0, 404, 301, 302, 307])) {
echo curl_getinfo($channel, CURLINFO_EFFECTIVE_URL) . ':'. $statusCode . "\n";
}
curl_multi_remove_handle($multi, $channel);
}
curl_multi_close($multi);
?>