PHP
[PHP] 사이트가 죽었는지 확인하기 Curl 이용
http://portfolio.wonpaper.net
2023. 11. 24. 11:12
<?php
$url = 'https://www.naver.com';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 1);
$result = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ( $httpcode==200 ) {
echo '죽지 않았음';
} else {
echo '죽었다.';
}
echo '1<br>';
flush();
sleep(1);
echo '2<br>';
flush();
sleep(1);
echo '3<br>';
flush();
sleep(1);
참고 : https://blog.naver.com/diceworld/220252714995