Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
curl 200 301 404 ..
<?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