Created
July 26, 2017 08:14
-
-
Save ildarkhasanshin/03690ff47dfa4370875f5d8862e4d8a8 to your computer and use it in GitHub Desktop.
curl 200 301 404 ..
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 | |
if ($curl = curl_init()) { | |
$hrefs = array( | |
'http://domain.com/page1.html', | |
'http://domain.com/page2.html', | |
'http://domain.com/page3.html', | |
'http://domain.com/page4.html', | |
'http://domain.com/page5.html', | |
); | |
foreach ($hrefs as $href) { | |
curl_setopt($curl, CURLOPT_URL, $href); | |
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); | |
curl_setopt($curl, CURLOPT_NOBODY, true); | |
curl_setopt($curl, CURLOPT_HEADER, true); | |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); | |
$out = curl_exec($curl); | |
$status200 = strpos($out, ' 200 '); | |
$status301 = strpos($out, ' 301 '); | |
$status404 = strpos($out, ' 404 '); | |
if ($status404) { | |
echo $href . '<br>' . $out . '<br><br>'; | |
} | |
} | |
curl_close($curl); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment