Skip to content

Instantly share code, notes, and snippets.

@ildarkhasanshin
Created July 26, 2017 08:14
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ildarkhasanshin/03690ff47dfa4370875f5d8862e4d8a8 to your computer and use it in GitHub Desktop.
Save ildarkhasanshin/03690ff47dfa4370875f5d8862e4d8a8 to your computer and use it in GitHub Desktop.
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